c++ - Why does Hello world not print in vim but it works in tty? -


in vim enter command :w | make. makefile looks this:

all:     g++ -o main main.cpp     ./main 

main.cpp looks this:

#include <iostream> using namespace std;  int main(){     cout << "hello world!"; } 

vim output says:

"main.cpp" 6l, 88c written :!make 2>&1| tee /tmp/ve16mwu/0 g++ -o main maincpp ./main (1 of 3): g++ -o main main.cpp press enter or type command continue_ 

now after quit vim , run executable: $ ./main output shows fine in terminal.

if put add newline \n line this: "hello world!\n" shows in vim's output fine.

apparently, in vim, output won't show last line of text if doesn't have \n on end. there workaround this?

endl cplusplus.com:

insert newline , flush

inserts new-line character , flushes stream.

so code this:

#include <iostream> using namespace std;  int main(){     cout << "hello world!" << endl;     return 0; } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -