![](/img/trans.png)
[英]OpenGL C++ with g++ compiler, not able to find GLFW on Windows 10 (no Visual Studio)
[英]Compliling C++ program in Visual Studio using g++ compiler generates % at the end
使用 g++ 編譯器在 Visual Studio Code 中編譯我的程序時,生成的輸出帶有%
符號。
#include <iostream>
int Main() {
std::cout << "Hello World!";
return 0;
}
終端截圖:
我把問號刪了,所以我認為沒有控制字符。
在符合 POSIX 的系統上,各個行按照慣例由換行符分隔。 zsh(這是您正在使用的外殼程序)使用%
表示缺少終止換行符的輸出。
嘗試在 shell 上輸入echo -n hello
以復制該行為。
要解決此問題(並刪除%
輸出),請在代碼的輸出中添加換行符:
…
std::cout << "Hello World!\n";
…
你是在 *nix 系統上寫這個嗎? 您沒有在“hello world”之后打印行尾,因此 % 符號可能是您的命令行提示符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.