我试图用两种不同的方式编写一个while循环,并注意到在两次条件下使用','不能按我认为的方式工作。我只是对实际发生的事情感到好奇。这是代码:
#include <stdio.h>
int main()
{
int i = 0, lim = 1000, c;
char s[lim];
while (i < lim - 1, (c = getchar()) != '\n')
{
if (c != EOF)
{
s[i] = c;
}
else
{
break;
}
++i;
}
printf("%s\n", s);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
#include <stdio.h>
int main()
{
int i = 0, lim = 1000, c;
char s[lim];
while (i < lim - 1, (c = getchar()) != '\n', c != EOF)
{
s[i] = …Run Code Online (Sandbox Code Playgroud)