vscode C++ 运行头文件
hello.h#include<stdio.h>#ifndef _STDIO_H_#define _STDIO_H_void hello();#endifhello.cpp实现hello.h#include"hello.h"#include<stdio.h>void hello(){printf("hello world");}mian.cpp#include"hello.
·
hello.h
#include<stdio.h>
#ifndef _STDIO_H_
#define _STDIO_H_
void hello();
#endif
hello.cpp实现hello.h
#include"hello.h"
#include<stdio.h>
void hello()
{
printf("hello world");
}
t.cpp
#include"hello.h"
int main()
{
hello();
}
vscode直接运行会报错
使用gcc -o t.cpp hello.cpp
把两个文件链接在一起,.\t
就可以运行了。

不要使用vscode的运行按钮来运行,输入命令来运行即可。
玩linux之后,确实喜欢通过输入命令来编译和运行来着。
更多推荐
所有评论(0)