2

Whenever I run my code a command prompt window appears and says "process returned 32762 (0x7FFA) execution time .009 seconds press any key to continue." I looked on google and couldnt find a solution.

I expect it to print "hello world"

here is my code

// my first C++ program
#include <iostream>
int main() {
    std::cout << "Hello, World";
    return 0;
}
user438383
  • 5,716
  • 8
  • 28
  • 43
Hezekiah Bodine
  • 141
  • 1
  • 13
  • The IDE im running is code::blocks – Hezekiah Bodine Dec 06 '20 at 02:53
  • 5
    "process returned 32762 [...]" is an error. I don't use code::blocks, but your code is correct, so it must be a problem with your IDE. – Ted Klein Bergman Dec 06 '20 at 02:57
  • I don't believe that this is a windows error code. Are you on a different OS? – drescherjm Dec 06 '20 at 03:02
  • Im using windows 10 – Hezekiah Bodine Dec 06 '20 at 03:04
  • Check and see if the executable was created. Also if you are using a different antivirus from the one that comes with the OS temporarily disable it and try again. – drescherjm Dec 06 '20 at 03:07
  • Turning off the firewall didnt help, I dont know if an executable was created or not, what would it be called? – Hezekiah Bodine Dec 06 '20 at 03:11
  • To be clear, `Hello World!` isn't appearing at all? That is to say, you're not in [a situation like this one](https://stackoverflow.com/q/36237213/10957435) where `Hello World!` appears but you wish to turn off the message after your code executes? –  Dec 06 '20 at 03:14
  • its not appearing at all – Hezekiah Bodine Dec 06 '20 at 03:16
  • What compiler do you use? – YSC Dec 06 '20 at 03:18
  • Also, what happens when you build the program without executing it (_Select "Build" menu ⇒ Build (Ctrl-F9)_)? – YSC Dec 06 '20 at 03:21
  • I did not mean the firewall. However from your response you must have the builtin AV. – drescherjm Dec 06 '20 at 03:22
  • I am using the GNU GCC Compiler, when I build the program without executing it it runs through and shows exit code 0 without actually printing "hello world" – Hezekiah Bodine Dec 06 '20 at 03:24
  • Actually when I build the program it denies me permission to open the executable file – Hezekiah Bodine Dec 06 '20 at 03:26
  • 1
    Try changing it to “Hello, World\n”. Formally, output must be terminated with a newline. – Pete Becker Dec 06 '20 at 03:29
  • @PeteBecker Are you sure that applies to C++? I'm only finding things about that for C. –  Dec 06 '20 at 03:39
  • The only reason you would need `'\n'` would be to flush the output buffer at some intermediate point in your code. However you exit after writing to `cout <<` so exiting would also flush `stdout` (though you really should add the `'\n'` but only so your program doesn't screw up my next prompt on the command line when I test it `:)` – David C. Rankin Dec 06 '20 at 08:50
  • If you have MinGW installed. Do yourself a favor. Add the path to `where\MinGW\bin` is to your environment. See [How do I add the MinGW bin directory to my system path?](https://stackoverflow.com/q/5733220/3422102) (your user-environment is the TOP box in the dialog) Restart `cmd.exe` (Command Prompt) if running. (File->Properties to set font, windows size, and set at least 1000 lines of scrollback). Now just change to the directory where your source file is and do `g++ -Wall -Wextra -o exe_name_you_want your_source.cpp` and run `exe_name_you_want.exe`. If not MinGW install is bad. – David C. Rankin Dec 06 '20 at 08:57
  • See [Same Error](https://www.learncpp.com/cpp-tutorial/writing-your-first-program/comment-page-13/#comment-470876) -- which ended up being system language related. – David C. Rankin Dec 06 '20 at 09:11
  • I have installed MinGW and put it into the path and changed pathext to accept .c files. The error is now that the .exe file doesnt exist (I looked it up in the directory and it isnt there) – Hezekiah Bodine Dec 06 '20 at 12:39
  • PS ive tried saving the file as a .cpp and I have tried turning off my antivirus software and firewall to no effect. – Hezekiah Bodine Dec 06 '20 at 18:19
  • I believe that there is something wrong with my path and it has to be reset. Im not actually going to do it though because it requires factory-resetting your computer to an extent and I dont want to deal with it. – Hezekiah Bodine Dec 19 '20 at 17:16

0 Answers0