我正在阅读C教程,#include
之后缺少某些东西:
/*** reads in n integers from a file,
then prints the values to another file as type float ***/
#include /*** for file manipulation functions ***/
#include /*** for malloc() ***/
main()
{
int i, n, *x;
char file_name[FILENAME_MAX];
FILE *fp;
printf("file name for input: "); scanf("%s", file_name);
fp = fopen(file_name, "r");
if (fp == NULL)
{
printf("error: could not open file %s\n", file_name);
exit(-1);
}
fscanf(fp, "%d", &n);
x = (int *) malloc(n * sizeof(int));
缺少什么?
答案 0 :(得分:3)
#include <stdio.h>
#include <stdlib.h>
你不能只搜索吗?
答案 1 :(得分:3)
#include <stdio.h> // for file manipulation
#include <stdlib.h> // for malloc()
这很容易谷歌。