示例
#include <stdio.h>
int main()
{
printf("Hello, World! \n");
int a = 5*10;
printf("你%d好, \n",a);
return 0;
}
linux下最方便。yum gcc。 编译gcc hello.c 执行 ./a.out
定义名字
gcc hello.c -o hello.out
window下rn Linux下n 换行
在 C 中,有两种简单的定义常量的方式: 使用 #define 预处理器。 使用 const 关键字。
枚举
enum DAY
{
MON=1, TUE, WED, THU, FRI, SAT, SUN
};
文件读写
#include <stdio.h>
int main()
{
FILE *fp = NULL;
fp = fopen("/tmp/test.txt", "w+");
fprintf(fp, "This is testing for fprintf...\n");
fputs("This is testing for fputs...\n", fp);
fclose(fp);
}