syntax error near unexpected token '\n'怎么办

来源:百度知道 编辑:UC知道 时间:2024/06/20 01:53:03
在Linux下编译时出现syntax error near unexpected token '\n'问题。
代码为:
#include<stdio.h>
#include <math.h>
main()
{
int m,i,k,h=0,leap=1;
printf("\n");
for(m=2;m<=100;m++)
{
k=(int)sqrt(m+1);
for(i=2;i<=k;i++)
if(m%i==0)
{
leap=0;
break;
}
if(leap)
{
printf("%-4d",m);
h++;
if(h%10==0)
printf("\n");
}
leap=1;
}
printf("\nThe total is %d\n",h);
}
请问怎么解决

http://www.linuxquestions.org/questions/linux-newbie-8/syntax-error-near-unexpected-token-newline-688261/

百度下就找到答案啦

问题在于 你把程序当成bash调用而不是perl调用
解决办法是 ./你的程序名 这样调用

我用vc6编译通过,应该不是代码的问题