首页 > 代码库 > 用vi写一个C 程序

用vi写一个C 程序

?
1
2
3
4
root@IdeaPad:~# ls
1.txt  3.txt  5.txt   6.py   evilxr      test
2.txt  4.txt  5.txt~  e.txt  evilxr.txt
root@IdeaPad:~# vi test.c

 

root@IdeaPad:~# cat test.c

#include <stdio.h>

int add(int a, int b)
{
    return a + b;
}

int main(int argc, char * argv[])
{
    int sum = 0,  x = 12, y = 14;
    sum = add(x, y);
    
    printf("hello evilxr.com!\n");
    printf("x = %d y = %d sum = %d",x, y, sum);
    return 0;

}
?
1
2
3
4
5
6
#编译文件
root@IdeaPad:~# gcc -o app test.c
#运行文件
root@IdeaPad:~# ./app
hello evilxr.com!
x = 12 y = 14 sum = 26