键盘上的enter键是换行符吗

在c语言里,多谢!

那要看是什么情况下了,也有可能是确定键,但是在word里就是换行符了追问

在c语言里呢?

追答

不是,'\n'是换行,实际是个转义字符,好像是13.这两行代码效果一样:printf("test%c",13);
printf("test\n");
记事本用老DOS定义.CRLF是回车换行.
CR -- "\r", LF -- "\n".
所以用"\r\n" 试试.
fprintf(fp2,"there are %d charactors:\r\n",n);

例如:
#include
#include
FILE * fp2;
main()
{
int n = 12345;
fp2 = fopen("abc.txt","w");
fprintf(fp2,"there are %d charactors:\r\n",n);
fclose(fp2);
printf("\007Output in abc.txt");
exit(0);
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-04-22
是!还是确认追问

在用c编代码时,我想统计一个txt文件里有多少个数字时(文件中数字间用空格或换行符隔开),判断这个字符是不是换行符if(c=='\n')或空格时if (c==' ')这么写你看对吗?
菜鸟一只···多谢指教

第2个回答  2012-04-22
相似回答
大家正在搜