Home  >  Article  >  Development Tools  >  How to compile and run notepad in c

How to compile and run notepad in c

藏色散人
藏色散人Original
2019-11-02 09:37:334896browse

How to compile and run notepad in c

notepad怎么编译运行c?

第一步:写入c代码

#include<stdio.h>
int main()
{
printf("hello world");
return 0;
}

第二步:按F5运行进行宏定义

cmd /k gcc -o "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" "$(FULL_CURRENT_PATH)" && CLS && "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" & PAUSE & EXIT

How to compile and run notepad in c

按下回车即可出结果

选择保存后可以选择一个快捷键,下次直接按下快捷键即可完美运行!

第三步:完美运行

How to compile and run notepad in c

补充

编译:

cmd /k gcc -Wall -o "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" "$(FULL_CURRENT_PATH)" & PAUSE & EXIT

运行:

cmd /k "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" & PAUSE & EXIT

关于脚本行:cmd /k gcc -o "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" "$(FULL_CURRENT_PATH)" && CLS && "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" & PAUSE & EXIT

cmd /k是弹出cmd窗口并执行后续指令。&和&&表示连接作用,说明有多行指令合为一行。

gcc -o “$(CURRENT_DIRECTORY)$(NAME_PART).exe” “$(FULL_CURRENT_PATH)” 编译生成.exe文件,输出源文件所在目录。注意这里需要有引号,目的是为了在目录及文件名存在空格的情况下也能够正常运行。

&& CLS 清屏。&&的意义在于,前面的语句出现错误,将不会执行该句。

&& “$(CURRENT_DIRECTORY)$(NAME_PART).exe” 运行刚刚生成的.exe文件。如果先前的编译错误,将不会运行。

& PAUSE 暂停,提示”按任意键继续“。这里无论前面有否错误,都将执行。因此我们看到的是编译错误,显示错误信息并暂停的窗口。

& EXIT 退出。

The above is the detailed content of How to compile and run notepad in c. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:how to download notepadNext article:how to download notepad