Need help with c++

I've been learning c++ using code blocks and I decided to try using visual c++ so I could eventually use directx sdk so in code block the hello world code I used was

#include <iostream>

Using namespace std

Int main()
{
cout << "hello world" << endl;
Return 0;
}

And it worked fine but when I use the same code in visual c++ it dose not work why is this?
Last edited on
No, that's certainly not the code you used.
Unlike regular languages like English, C++ doesn't let you get away with mistakes.
I learned it on thenewboston.com and in code blocks it works fine I know that's the easiest code there is but i don't understand why it doesn't work in visual c++ express
I think I made it clear enough that you didn't copy the code properly. So check the site again.
Capitalization matters and you forgot a semicolon.
Last edited on
I accidentally forgot the ; after namespace std om my post but still I have that in the code in code blocks and when I compile it I get hello world but when I copy the same code and paste it in visual c++ and compile it I get errors
C++ is case sensitive. You have used upper case letters on 3 places where it shouldn't be used.
Sorry about that also the forum made it capital but just trust me on it worked in code blocks but the same code I out in visual c++ doesn't I just dont understand why it wouldent.
Can you at least tell me it should work so I know I'm using the rite things
"The forum made it capital"? Either you're using a very strange browser or... well, it doesn't need to be said.
In any case, copy & paste the error messages and make sure no mysterious alterations happen this time.
I don't have visual c++ but it should work.
1
2
3
4
5
6
7
8
9
#include <iostream>

using namespace std;

int main()
{
	cout << "hello world" << endl;
	return 0;
}


What error message do you get?
Ok on visual c++ I was getting errors cause I was using win32 application so I used console application and it pops up for only a second

The exact code is

#include <iostream>

using namespace std;

int main()
{
cout << "Hello world!" << endl;
return 0;
}

But why in visual c++ does it pop up and instantly go away
Also why doesn't it work in win32 application I know it's still c++ but why doesn't it work
closed account (zb0S216C)
Visual C++ doesn't automatically keep the console from closing - Code::Blocks does. You'll have to incorporate your own anti-console-closing method.

The reason why it doesn't work as a Win32 application is because the entry-point is different from the conventional main(); typically, in Visual C++, it's _tWinMain(). You'll have to setup the project to a Win32 application. I should advise you that the code required to get a simple Win32 program up and running is far more challenging than that of a console.

Wazzak
Last edited on
Ok thank you also is thenewboston.com c++ tutorial a good way to start learning c++ or should I go ahead and use books. I'll continue learning c++ and eventually I'll figure this out.
Yeah, it's a bad way to learn C++ (and so are the vast majority of other video tutorials).
You should use a book such as the C++ Primer.
closed account (zb0S216C)
TheNewBoston is a good source, but not that good. Put it this way, I wouldn't lean on his teachings too much. Read books if you can. Books go into more detail. The Lamborghini's of books are well structured, offer analogies, examples and are written by well known experts - even the creator himself - Bjarne.

I should mention 3 websites that are definitely reliable sources:
1) http://www.cplusplus.com
2) http://www.cprogramming.com
3) http://www.learncpp.com

Wazzak
Last edited on
But why in visual c++ does it pop up and instantly go away
Use Ctrl+F5 to run it
Topic archived. No new replies allowed.