热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_63271944
叶随风动~
5 年前
trueweixin_63271944

新手开始编译
打开windows power shell
输入
cd D:\c-primer
<将在低权限编译>
notepad hello.c
开始编译
<“;”经常容易忘记>


#include <stdio.h>

int main()
{
printf("Hello,world!");

return 0;
}



输出文件



gcc hello.c -o hello.exe
<其中“-o”为“指定输出文件(名)”>


若无反应
运行程序


./hello


如何捕捉程序运行的瞬间(这个程序运行极快)
查看文件 cat .\hello.c (然后出现该.c文件代码)
<键盘↑↓键可以切换已输入指令>
在.c文件中输入一个死循环


for(;;);


<输入control+c停止运行程序>


#include <stdio.h>

int main()
{
char buffer[40]

printf("input your name: ");
fgets(buffer, [40], stdin);
printf(“your name is %s",buffer);

return 0;
}



计算圆面积
#include <stdio.h>

int main()
{
float radius;
radius = 2;
float pi = 3.14159;
float s = pi * radius * radius;
printf("The area of a circle with a radius of %f is %f\n",radius, s)

return 0;
}

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
1024程序节https://1024.csdn.net/
立即登录