凡把文件以及如何编译和运行呢? [英] Where to put the file and how to compile and run it?

查看:114
本文介绍了凡把文件以及如何编译和运行呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想学习如何编写Linux下的C程序。现在我已经安装了CentOS,和我使用 VIM 来写C语言中的世界你好程序。但我不知道在哪里把它,或者如何去编译它?我已经安装了 GCC 。对不起。我是一个新手。谢谢。你能不能让我一个例子,如何用C来写一个简单的程序,然后测试和编译。

I want to learn how to write a C program under Linux. Now I have installed Centos, and I'm using vim to write a 'hello world' program in the C language. But I don't know where to put it, or how to compile it? I have installed gcc. I am sorry. I am a newbie. Thank you. Could you make me an example how to write a simple program in C then test and compile it.?

推荐答案

键入:

$ mkdir ~/learnC
$ cd ~/learnC
$ cat > hello.c 

   #include <stdio.h> 
   int main () { 
      printf("Hello World\n"); 
   } 

/* Press Ctrl+D */

$ gcc hello.c -o hello
$ ./hello

这篇关于凡把文件以及如何编译和运行呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆