Computing.Net > Forums > Programming > C++ newbie

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C++ newbie

Reply to Message Icon

Name: goaliemike
Date: February 24, 2005 at 13:22:47 Pacific
OS: xp pro
CPU/Ram: 512 ddr amd xp 2000+
Comment:

Hey ive lerned java, basic and ms visual J++. Now im lerning C++ and usually the first exercise is to display a window with the classic Hello World. Im using Dev C++ and the first basic thing dosnt work. whats worng in this; the said to try the 2nd if this didnt work but no sucess

#include <iostream.h>

int main()
{
count <<"Hello World!\n";
return 0;
}

now here is the 2nd

#include <iostream.h>

int main();
int main()
{
count <<"Hello World!\n";
return 0;
}

Im only 14, so dont blame me

AMD athlon xp 2000+
ECS K7S5A Pro
512 MB DDR ram
Sapphire atlantis 9200se
8 GB quantum fireball
30 GB Maxtor Diamondmax 60 GB Maxtor Diamondmax



Sponsored Link
Ads by Google

Response Number 1
Name: HiJinx
Date: February 24, 2005 at 13:28:10 Pacific
Reply:

Change count to cout


0

Response Number 2
Name: Dark_Kartug
Date: February 24, 2005 at 23:51:13 Pacific
Reply:

Also dont put a ; after int main() and add using std::cout; (you could also just add using namespace std; to add the entire namespace)

Complete code should look like this

#include <iostream>
using std::cout;
using std::endl;

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

War sucks, but the sound is good and WE are the DJ's


0

Response Number 3
Name: BlueRaja
Date: February 25, 2005 at 18:24:05 Pacific
Reply:

Ignore Dark:
1. int main(); is the declaration (not the definition). Although I don't know why it was there, it's perfectly legal.
2. the std namespace is only used when using the standard iostream library; "using std::cout" is not necessary when using "#include <iostream.h>"

BlueRaja.admin@gmail.com


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C++ newbie

c++ newbie www.computing.net/answers/programming/c-newbie/16448.html

stupid C newbie question www.computing.net/answers/programming/stupid-c-newbie-question/430.html

C++ help for beginner www.computing.net/answers/programming/c-help-for-beginner/9720.html