#include <stdlib.h>
#include <string.h>
int main(void){
double sum=0;
int ii=0;
char buf[256], token[100]; // I am making this "finite length". You need to know how long the line is that you allow...
printf("Enter the numbers to average on a single line, separated by space, then press <ENTER>\n");
gets(buf, 255, stdin);
token = strtok(buf, " ");
while(token != NULL) {
sum += atof(token);
ii++;
token = strtok("", " "); // get next number
}
printf("AVERAGE: ***** %lf\ *****", sum / (double)ii);
return 0;
}
它给出了这个错误 - 第 9 行:stdin undeclared & 当我添加 stdio.h 头文件时,它给了我错误 - 第 11 行:预期左值
任何人都可以纠正它吗?