实验一:写一个hello world小程序

实验一:写一个hello world小程序

实验要求

写一个hello world小程序:linux

  • 实验楼Linux环境使用C语言编写,编译后执行输出"Hello,World!";
  • 实验和实验报告务必在实验楼linux下完成,课程视频是在本地虚拟机上操做的,除了目录环境和做业提交方式不一样外,基本的命令和编辑操做方式是一致的。

实验过程参考

  • 进入实验目录并建立实验一文件夹lab1
shiyanlou:~/ $ cd Code/shiyanlou_cs122
shiyanlou:shiyanlou_cs122/ (master) $ mkdir lab1
shiyanlou:shiyanlou_cs122/ (master) $ cd lab1
shiyanlou:lab1/ (master*) $ vi hello.c
  • 使用vi编辑hello.c文件
#include <stdio.h>

int main()
{
    printf("hello world!\n");
}
  • 编译执行hello程序
shiyanlou:lab1/ (master*) $ ls
hello.c
shiyanlou:lab1/ (master*) $ gcc -o hello hello.c
shiyanlou:lab1/ (master*) $ ./hello             
hello world!
shiyanlou:lab1/ (master*) $
  • 提交代码到版本库(注意不要使用视频中要求的打包文件提交做业),具体方法能够参考https://www.shiyanlou.com/questions/360
shiyanlou:lab1/ (master*) $ git add hello.c
shiyanlou:lab1/ (master*) $ git commit -m "hello world"
[master 40425fe] hello world
 1 file changed, 7 insertions(+)
 create mode 100644 lab1/hello.c
shiyanlou:lab1/ (master*) $ git push
......

Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 339 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@git.shiyanlou.com:mengning/shiyanlou_cs122.git
   5f24b93..40425fe  master -> master
shiyanlou:lab1/ (master*) $

实验报告要求

完成实验报告并公开发表(要求使用实验楼的实验报告),具体要求以下:git

  • 简述本身的实验的思路和具体过程;
  • 引用实验中本身添加或修改的部分关键代码;
  • 至少有一张实验关键代码截图,至少有一张实验运行结果截图;
  • 将本身在实验中遇到疑惑和困难,以及本身的处理方法,实验心得等写入实验报告;
  • 实验报告的最后作一个简要的实验总结;
  • 将实验报告的URL提交到网易云课堂MOOC平台,编辑成一个连接能够直接点击打开。

测试本身的实验代码,复审本身的实验报告

请务必确认您提交的实验报告中的实验代码能够直接启动实验环境进行以下操做小程序

shiyanlou:~/ $ cd Code/code_refer 
shiyanlou:code_refer/ (master) $ ls
README.md  hello.c  lab1
shiyanlou:code_refer/ (master) $ cd lab1 
shiyanlou:lab1/ (master) $ gcc -o hello hello.c 
shiyanlou:lab1/ (master*) $ ./hello
hello world!
shiyanlou:lab1/ (master*) $ vi hello.c
相关文章
相关标签/搜索