示例C中的程序(不带标题):
int main()
{
printf("\nHello World\n");
}
我怎么知道应该
包含什么标题(例如:#include <stdio.h>
)?
答案 0 :(得分:7)
考虑到您可能无法在线搜索(我猜大多数时候这是很明显的选择),并且您使用的是Linux计算机,也可以在手册页中进行搜索。
要在手册页中进行搜索,可以使用man -k {search term}
例如printf
$ man -k printf
asprintf (3) - print to allocated string
dprintf (3) - formatted output conversion
fprintf (3) - formatted output conversion
fwprintf (3) - formatted wide-character output conversion
printf (1) - format and print data
printf (3) - formatted output conversion
snprintf (3) - formatted output conversion
sprintf (3) - formatted output conversion
swprintf (3) - formatted wide-character output conversion
vasprintf (3) - print to allocated string
vdprintf (3) - formatted output conversion
vfprintf (3) - formatted output conversion
vfwprintf (3) - formatted wide-character output conversion
vprintf (3) - formatted output conversion
vsnprintf (3) - formatted output conversion
vsprintf (3) - formatted output conversion
vswprintf (3) - formatted wide-character output conversion
vwprintf (3) - formatted wide-character output conversion
wprintf (3) - formatted wide-character output conversion
XtAsprintf (3) - memory management functions
$ man 3 printf
PRINTF(3) Linux Programmer's Manual PRINTF(3)
NAME
printf, fprintf, dprintf, sprintf, snprintf, vprintf, vfprintf, vdprintf, vsprintf, vsnprintf - formatted output conversion
SYNOPSIS
#include <stdio.h>
int printf(const char *format, ...);
int fprintf(FILE *stream, const char *format, ...);
...
答案 1 :(得分:5)
答案 2 :(得分:-2)
将此用作参考C library reference,以使您的代码可以使用此
#include <stdio.h>