基本上,我一直在上C类编程,在该类中我们使用Linux机器来编写和编译我们的代码.
下面的程序是我们第一个任务的一部分,我编译它并在课堂上在Linux上运行它没有任何问题,但是把它带回家我不能在我的生活中让它在Visual Studio 2010 ultimate中编译,或者使用MinGW编译器的eclipse IDE.
是否存在导致我的代码失败的两个操作系统之间切换的典型问题?还是我,作为我的新手,写了一些丑陋的代码,这些代码与VS 2010或Eclipse不同意?
尝试修复我从VS 2010获得的错误消息似乎是徒劳的,所以我倾向于从我的计算机中缺少必要的东西.我还设置VS 2010来编译C代码,所以我不认为这是问题.
来自VS2010的错误:
project1a.c(38):错误C2143:语法错误:缺少';' 在'
type'project1a.c(41)之前:错误C2065:'i':未声明的标识符
project1a.c(44):错误C2065:'userArray':未声明的标识符
project1a.c(44):错误C2065:'i':未声明的标识符
project1a.c(44):错误C2109:下标需要数组或指针类型
project1a.c(51):错误C2065:'userArray':未声明的标识符
"i"有多个实例:这些错误之间存在未声明的标识符错误
#include <stdio.h>
#include <stdlib.h>
int n;
float total, avg;
int sumavg(void);
int main(void)
{
//First time scan for the value to be assigned to n.
printf("Hey, Enter a number or 999 to exit:> ");
scanf("%d", &n);
//if n == 999 then exit the program
while(n != 999)
{
//enter the sumavg function.
sumavg();
//Try to run the program again.
printf("Hey, …Run Code Online (Sandbox Code Playgroud)