c语法在两个不同的行中?

tom*_*aas 0 c coding-style

我有关于c语法的这个简单问题.当我们写:

  printf("hello world
  ");
Run Code Online (Sandbox Code Playgroud)

编译器产生错误.为什么?在另一个案例中:

  for (i = 0; i < MAXLINE - 1      
  && (c=getchar)) != EOF && c != '\n'; ++i)
Run Code Online (Sandbox Code Playgroud)

一切都很好.这一切的一般规则是什么?

谢谢 !

SLa*_*aks 9

字符串文字("...")不能包含裸换行符.

如果你想在字符串中使用换行符,请使用\n转义序列(`"hello world \n")