【问题标题】:Gitpod to run a C hello world programGitpod 运行一个 C hello world 程序
【发布时间】:2021-01-18 16:19:16
【问题描述】:

我是 C 语言的新手,但我将 Gitpod 用于其他语言。我想知道如何从Gitpod界面一步步运行这个简单的“hello world”main.c程序?

#include <studio.h>
void main(){
    printf("hello")
}

非常感谢!

【问题讨论】:

  • studio -> stdio.h, main() 必须返回一个int 并且printf() 需要一个分号结尾。

标签: c linux visual-studio-code ide gitpod


【解决方案1】:

修复错误后,您可以使用gcc main.c 编译代码并运行二进制文件a.out。 已经提到的错误:

  • studio.h -> stdio.h
  • ...hello") -> ...hello");

【讨论】:

  • 感谢伍尔夫·蒂姆。此时代码中的错误对我来说并不是真正的重点。以及如何运行代码解决了我的问题。
【解决方案2】:

在 printf("hello") 之后 你应该把;

//like this
printf("hello");

【讨论】:

    【解决方案3】:
    #include <stdio.h>
    int main(){
        printf("hello");
        return 0;
    }
    

    【讨论】:

    • 请在您的答案中添加一些解释,以便其他人可以从中学习
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多