/*
Low Level I/O - Read and Write
Chapter 8 - The C Programming Language - K&R
Header file in the original code is "syscalls.h"
Also BUFSIZ is supposed to be defined in the same header file
*/
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#define BUFSIZ 1
int main() /* copy input to output */
{
char buf[BUFSIZ];
int n;
while ((n = read(0, buf, BUFSIZ)) > 0)
write(1, buf, n);
return 0;
}
当我输入“∂∑∑®†¥¥¥˚πΔ~~∫∫√ç tu 886661~EOF”作为输入时,它会被复制。有多少非 ASCII 字符同时存储?
BUFSIZ 是要传输的字节数。如果对于任何值,任何内容都可以从输入复制到输出,BUFSIZ 如何限制字节传输?
char buf[BUFSIZ] 如何存储非 ASCII 字符?