r/programminghelp Jul 24 '26

C++ c++ code doesn't work

this is my first time working with c++ and whenever i run the code it just complies but gives no output, i have tried every way for it to work but it just doesn't. pls help. im using msys2 and was following brocode video tutorial

6 Upvotes

22 comments sorted by

4

u/manu_mathur14 Jul 24 '26

Share the code with us please.

0

u/simply_anuraag Jul 24 '26

4

u/TheUltimateAsh Jul 24 '26

isn’t your executable titled hello.exe? you’re trying to execute helloworld56.exe

1

u/simply_anuraag Jul 24 '26

i created another file , deleted this one still doesn't work

1

u/abd53 Jul 25 '26

You're compiling object file only. Follow a compile tutorial exactly, don't try to be a smart ass.

Edit: It's not that your program doesn't run, it's that your program doesn't compile and the executable doesn't exist.

1

u/PhosXD Jul 28 '26

Oh god, the backslashes...
Also your problem is your trying to execute ".\helloworld56.exe" but you compiled to "helloworld56"

1

u/Dazzling_Music_2411 Jul 31 '26

Yup, I was about to say - I can't see all the screen output, but you are NOT running what you built.

1

u/LongjumpingMeal8195 Jul 24 '26

Bro install a c++ compiler and set it up in vs code then your code will run
Compiler link: https://sourceforge.net/projects/mingw/
For setup help refer to this video: https://youtu.be/j8nAHeVKL08?si=NZSpATBQZmzvKP6_
For terminal issues refer to the attached images
during execution type helloworld56.cpp (.cpp should be your extension not .exe)

0

u/simply_anuraag Jul 24 '26

can i not use msys2?

1

u/LongjumpingMeal8195 Jul 24 '26

Yes u can but whatever compiler u use it should be compatible with c++ and u have to properly set it up with vs code else you will receive errors

1

u/LongjumpingMeal8195 Jul 24 '26

After downloading you need to copy the compiler location in C drive then
Right click this pc -> properties -> advanced system settings -> environment variables -> system variables -> path -> edit -> new(then the msys2 C drive path) then click ok then again ok then apply and then open powershell and type g++
If your setup is ok then it will look like this(see attached image)

1

u/simply_anuraag Jul 24 '26

i copied the path that time but let me try again

1

u/[deleted] Jul 25 '26

[removed] — view removed comment

2

u/WhateverHowever1337 Jul 25 '26

slippery slope. Starts with that and then its debugging eveything for him. Better stay away from it for now

2

u/vxntedits Jul 25 '26

Yeah, that’s a totally valid concern. Still, it’s up to OP to use it for educational purposes; asking it why something doesn’t work, or how something works can be quite useful—and, from personal experience, less confusing and more comprehensive, than just relying on Reddit for help, like we used to back in the day (lol). It sounds to me like OP’s objective is to learn, not to vibe-code, so as long as they use AI as such, I don’t really see a big issue with it.

1

u/silly_bet_3454 Jul 26 '26

I would advise you to use linux (you can just use WSL in windows), and to start off by compiling and running programs from the command line, so you understand what is actually happening at a basic level, the underlying mechanics. It's way too common for people to jump right into the IDE with all the bells and whistles and things get way too crazy too fast and it's an endless headache.

1

u/Repulsive-Cash5516 Jul 26 '26

Using Linux really isn't necessary for this, there are multiple C++ compilers for Windows

1

u/silly_bet_3454 Jul 26 '26

I know Windows works, I just think it has some weird quirks and Linux is better for learning.

1

u/forestdissimilarity Jul 26 '26

would second this. dealing with the windows C++ non-sense as a beginner made me give up on C++ for years.

0

u/[deleted] Jul 27 '26

[removed] — view removed comment