#running .cpp on WSL

42 messages · Page 1 of 1 (latest)

thick ibex
#

after executing the code why it does not start a new line

xxxx@MSI:~/compsci/proj/cpp$ ./sample
Hello Worldxxxx@MSI:~/compsci/proj/cpp$

the code

#include <iostream>
using namespace std;

int main()
{
    cout<<"Hello World";
    return 0;
}
elfin ridgeBOT
#

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.

thick ibex
#

it is quite annoyning, how to fix it

opaque cedar
#

learn c++ via books or something

elfin ridgeBOT
#
How to Learn C++ Programming

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:

<:microsoft:1165512917047853127> Windows
  • [Visual Studio](#1165492293810257920 message)
  • CLion
<:tux:1165505626894520361> Linux
<:apple:1165508607798943754> Mac
opaque cedar
#

this is about esc seq

#

you need add new line, via special symbol

thick ibex
#

via university but professor have never taught wsl

opaque cedar
#

it not relate to wsl

thick ibex
#

in normal windows vscode it automatically start a new line

#

but wsl does not

#

why

opaque cedar
#

you just wrote code wrong (if you expect it to start with new line)

thick ibex
#

no i mean i want it

xxxx@MSI:~/compsci/proj/cpp$ ./sample
Hello World
xxxx@MSI:~/compsci/proj/cpp$
cinder hull
thick ibex
#

not

Hello Worldxxxx@MSI:~/compsci/proj/cpp$```
opaque cedar
#

so you need to write

#

new

#

line

#

\n

#

or std::endl

thick ibex
#

but i see others youtubers have a automatically start new line

#

without writting it

opaque cedar
#

dont look to youtube

opaque cedar
cinder hull
viscid cloud
#

as most of the time

thick ibex
#

ok

#

!solved

elfin ridgeBOT
#

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

thick ibex
cinder hull
#

Terminal wasnt the right choice for a word

thick ibex
#

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.```
opaque cedar
#

feels like gpt output

thick ibex
#

yeb

#

is this good or not

#

will it cause any prob

#

for running multi file tasks

daring sundial
daring sundial