c - 这里缺少哪些头文件(C 代码)?

标签 c code-analysis

我正在阅读 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));

缺少什么?

最佳答案

#include <stdio.h> // for file manipulation
#include <stdlib.h> // for malloc()

这很容易通过谷歌搜索。

关于c - 这里缺少哪些头文件(C 代码)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9218237/

相关文章:

c# - 代码分析规则集的层次结构?

C 克服别名限制( union ?)

c - 如何忽略 C 中变量的符号?

c# - 各种 Microsoft.CodeQuality.* 分析器之间有什么区别?

c# - 未找到类型或命名空间 "are you missing assembly reference"而所有引用都正确

c# - 这位讲师对 C# 工具的评论是什么意思?

c - mifare desfire 中的 ISO14443-4(RATS)

c - 如何使用自定义 libopenssl 构建 openldap

c++ - 库构建系统是否应该默认关闭断言?

visual-studio-2008 - 代码分析是否支持为混合语言拼写检查定义两种语言?