Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 20th, 2005, 2:48 PM   #11
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Smile

Quote:
Originally Posted by Xero
www.cplusplus.com has some of the basics

You're best bet is to buy a book for C++. You can't just learn from reading though.
I agree,
http://www.cplusplus.com/doc/tutorial/index.html
is very thorough from the start on up.

For a book I recommend "Standard C++ Bible" by Al Stevens and Clayton Walnum. It has a CD-ROM with all the sample code from the book and an integrated compiler, so you can run the code and most importantly experiment with it. That's the way to learn!!!
Dietrich is offline   Reply With Quote
Old Feb 20th, 2005, 8:41 PM   #12
Floppie
Newbie
 
Join Date: Feb 2005
Posts: 18
Rep Power: 0 Floppie is on a distinguished road
http://www.cprogramming.com/ also has some helpful tutorials~
Floppie is offline   Reply With Quote
Old Feb 20th, 2005, 9:11 PM   #13
quitter
Newbie
 
quitter's Avatar
 
Join Date: Feb 2005
Posts: 9
Rep Power: 0 quitter is on a distinguished road
Send a message via ICQ to quitter Send a message via AIM to quitter
Quote:
Originally Posted by Dietrich
I agree,
http://www.cplusplus.com/doc/tutorial/index.html
is very thorough from the start on up.

For a book I recommend "Standard C++ Bible" by Al Stevens and Clayton Walnum. It has a CD-ROM with all the sample code from the book and an integrated compiler, so you can run the code and most importantly experiment with it. That's the way to learn!!!

I use that site but wen i compile it and try to run it all it does is cmd opens real fast and closes right away...
i tried what they gave me which was this

Quote:
// my first program in C++

#include <iostream.h>

int main ()
{
cout << "Hello World!";
return 0;
}
which doesnt really work.. i get the error which i explained already, but when i try this one

Quote:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
cin.get();
return 0;
}
It works cmd opens and i can read hello world.. can someone explain whats hte difference? what exactly does << endl; do?
__________________
Welcome to the real world...
quitter is offline   Reply With Quote
Old Feb 20th, 2005, 9:33 PM   #14
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 6 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
This would be better..

#include <iostream>
#include <conio.h>
using namespace std;

int main() {
    cout << "Hello world!" << endl;
    // endl = End of line, ends the output line and starts a new one...

    cout << "endl put this here... ";
    cout << "instead of here.";

    getch();
    // included by conio.h
    //   - Waits for keyboard input and the continues...
    //   - Shows nothing on the screen...

    return 0;
}
__________________


Last edited by tempest; Feb 20th, 2005 at 9:37 PM.
tempest is offline   Reply With Quote
Old Feb 20th, 2005, 10:01 PM   #15
quitter
Newbie
 
quitter's Avatar
 
Join Date: Feb 2005
Posts: 9
Rep Power: 0 quitter is on a distinguished road
Send a message via ICQ to quitter Send a message via AIM to quitter
cool htat works too... what does conio.h do?
__________________
Welcome to the real world...
quitter is offline   Reply With Quote
Old Feb 20th, 2005, 10:26 PM   #16
Xero
Hobbyist Programmer
 
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 4 Xero is on a distinguished road
LOL forget that

just add:
int fsd;
cin >> fsd;

put this at the very end right before return 0;
its cuz some compilers just terminate immediately after execution. Yea, I was quite confused too when I switched compilters from the Borland to Visual Studio .Net (I think). I still don't know why though, but you probably have to add a cin or get char/line or whatever to pause.
__________________
...
Xero is offline   Reply With Quote
Old Feb 21st, 2005, 1:45 PM   #17
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Stick with cin.get();. cin >> fsd; uses an unneeded variable, and while getch(); works, it may not work on a different compiler.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 21st, 2005, 11:30 PM   #18
quitter
Newbie
 
quitter's Avatar
 
Join Date: Feb 2005
Posts: 9
Rep Power: 0 quitter is on a distinguished road
Send a message via ICQ to quitter Send a message via AIM to quitter
oooh i get it!
__________________
Welcome to the real world...
quitter is offline   Reply With Quote
Old Feb 21st, 2005, 11:34 PM   #19
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 6 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
getch() is the best option on a windows compiler. However if you move to linux you have to look to cin alternatives.

As for not working with other (windows) compilers, conio.h was originally developped by borland and as far as i know is currently supported on Microsoft, Borland, and Bloodshed compilers.
__________________

tempest is offline   Reply With Quote
Old Feb 22nd, 2005, 2:12 AM   #20
ZenMasterJG
Hobbyist Programmer
 
ZenMasterJG's Avatar
 
Join Date: Nov 2004
Location: Boston, MA
Posts: 148
Rep Power: 4 ZenMasterJG is on a distinguished road
Send a message via AIM to ZenMasterJG
conio.h is also evil
(Personal opinion, at least)
ZenMasterJG is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:41 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC