日期:2014-05-16  浏览次数:20676 次

read 赋值问题
read 赋值问题
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
int main()
{
char buffer[4];
int a;

a = read(0, buffer, 4);
if (a = -1)

write(2, "abc\n", 3);

exit (0);
}


如果输入4位以上的话 他是会返回-1吗?

如果返回-1的话

他是不是因该返回我输入的字符串前3位啊??

为啥输入超过4位以上。。。这个例子报错啊。。。

新手 请教

------解决方案--------------------
a=-1和a==-1