我有个问题关于以下代码:GETC与Windows VS的Unix
while((c = getc(pFile)) != EOF)
{
if(c != '\n')
{
input[index] = (char)c;
index++;
} else
{
input[index] = '\0';
index = 0;
}
}
在Windows中,此C = GETC行读取 '\ n'(代码10)的两倍。例如,我读取文件与以下两行:
Hello world Test
C = GETC在世界你好读取,但在读出图10(\ n)和10一次,复位输入数组为空(因为'\ 0')。在unix中,'\ n'只读取一次,所以它一切正常。
有什么想法?
在此先感谢。
也许它关系到如何文件具有其最终的行信号? – woliveirajr
@ user834005:你如何打开文件? – Hasturkun
pFile = fopen(“input.txt”,“a +”); – ibm1