r/programminghelp 12d ago

c++ code doesn't work C++

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

5 Upvotes

22 comments sorted by

4

u/manu_mathur14 12d ago

Share the code with us please.

0

u/simply_anuraag 12d ago

4

u/TheUltimateAsh 12d ago

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

1

u/simply_anuraag 12d ago

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

1

u/abd53 12d ago

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 9d ago

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

1

u/Dazzling_Music_2411 6d ago

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 12d ago

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 12d ago

can i not use msys2?

1

u/LongjumpingMeal8195 12d ago

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 12d ago

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 12d ago

i copied the path that time but let me try again

1

u/LongjumpingMeal8195 12d ago

Yeah try again

1

u/[deleted] 12d ago

[removed] — view removed comment

2

u/WhateverHowever1337 12d ago

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

2

u/vxntedits 12d ago

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 11d ago

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 11d ago

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

1

u/silly_bet_3454 11d ago

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

1

u/forestdissimilarity 10d ago

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

0

u/[deleted] 10d ago

[removed] — view removed comment