-
May 9th, 2019, 05:13 AM
#1
Hello world prgram not runing
I wrote this hello world program from tutorial yesterday and it was running but now it is not. I have windows 10, and using visual studio 2017. When I go to Deub tab, the start debugging option can not be highlighted, it is gray. How can I run this again?
Code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
system("pause");
return 0;
}
Last edited by 2kaud; June 4th, 2019 at 06:48 AM.
Reason: Added code tags
-
May 9th, 2019, 08:32 AM
#2
Re: Hello world prgram not runing
Does the .exe file exist? If not - try to rebuild.
Victor Nijegorodov
-
May 14th, 2019, 04:53 AM
#3
Re: Hello world prgram not runing
@Ketanco
Have you created a Windows Console Project or is something else?
-
May 28th, 2019, 12:54 PM
#4
Re: Hello world prgram not runing
Check the properties of your solution and see that your executable is set as the startup project.
-
May 31st, 2019, 09:05 PM
#5
Re: Hello world prgram not runing
Make sure the build mode is set to Debug, not Release.
-
June 4th, 2019, 04:22 AM
#6
Re: Hello world prgram not runing
You should add:
Code:
#include <Windows.h>
You should also ensure your project is set to run as a Windows Application and not a Console Application.
Windows Applications often don't accept 'cout <<'. You'd need to use:
Code:
MessageBox(NULL, "Hello World!", "Hello!", MB_OK);
If you're not using WinAPI then make sure your program is running as a CONSOLE APPLICATION. You can use 'cout <<' with Console Applications with no problems.
Project > Properties > Linker > First option set it to 'Console Application' or 'Windows Application' depending on how you want to code...
Last edited by Arianax; June 4th, 2019 at 04:26 AM.
-
June 4th, 2019, 06:53 AM
#7
Re: Hello world prgram not runing
Originally Posted by Arianax
You should add:
Code:
#include <Windows.h>
You should also ensure your project is set to run as a Windows Application and not a Console Application.
Windows Applications often don't accept 'cout <<'. You'd need to use:
Code:
MessageBox(NULL, "Hello World!", "Hello!", MB_OK);
If you're not using WinAPI then make sure your program is running as a CONSOLE APPLICATION. You can use 'cout <<' with Console Applications with no problems.
Project > Properties > Linker > First option set it to 'Console Application' or 'Windows Application' depending on how you want to code...
The program in post #1 is a console program so cout should be used and #include<windows.h> and MessageBox() should not used.
As the OP has not posted further since the post #1, I'm guessing that the problem has been solved.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|