#running .cpp on WSL
42 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
it is quite annoyning, how to fix it
learn c++ via books or something
We generally recommend a good book to learn the necessary fundamentals:
To actually write and run C++ code, you will need a compiler, editor, and debugger. We strongly recommend to start out using an IDE, which will provide all these tools for you:
- [Visual Studio](#1165492293810257920 message)
- CLion
via university but professor have never taught wsl
it not relate to wsl
you just wrote code wrong (if you expect it to start with new line)
no i mean i want it
xxxx@MSI:~/compsci/proj/cpp$ ./sample
Hello World
xxxx@MSI:~/compsci/proj/cpp$
You did not print newline at the end
not
Hello Worldxxxx@MSI:~/compsci/proj/cpp$```
dont look to youtube
try book
It depends on the terminal
you didn't add a newline or emptied the stdout buffer. WSL (or Linux) is right, windows is wrong
as most of the time
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
thx
thx
Terminal wasnt the right choice for a word
just find sth interesting
This command adds a newline before your shell prompt, making the output cleaner.
🔍 Breakdown:
PS1 is the shell prompt string — it defines how your prompt looks.
' \n' prepends a newline character.
'$PS1' keeps your existing prompt format.
So this line updates your prompt to start on a new line every time.
🔧 Example:
Before:
ruby
Hello, World!user@hostname:~$
After running:
sh
PS1='\n'$PS1
You'll get:
ruby
Hello, World!
user@hostname:~$
Much cleaner for output-heavy programs!
🔒 Make It Permanent (Optional)
To always have this newline, add the line to your ~/.bashrc:
sh
echo "PS1='\n'\$PS1" >> ~/.bashrc
Then reload:
sh
source ~/.bashrc
⚠️ Note:
This doesn't fix program output formatting — it's only a cosmetic improvement for your shell experience. You should still add \n or endl in your C++ programs for proper output control.
Let me know if you want to customize your prompt even more.```
feels like gpt output
It's not bad inherently
It just taught you the wrong lesson
Just use \n on any output string