GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-Sep-2003, 19:46
deleted_1 deleted_1 is offline
New Member
 
Join Date: Sep 2003
Posts: 7
deleted_1 is an unknown quantity at this point

Teach Yourself in 24 Hours?


Hello all! I'm just starting out with that book called Sams Teach Yourself C++ in 24 Hours, Third Edition. Anyways I had a question... I'm on hour 3 now and so far every program they have you make, like that first "Hello World" one, dont run right I dont think. I compile them and all without any errors but when I go to run them they just pop up REAL FAST and then close... I mean you can bearly see that it even opened because it closes so fast! Is this whats supposed to happen?

Thanks
  #2  
Old 01-Sep-2003, 20:28
deleted_1 deleted_1 is offline
New Member
 
Join Date: Sep 2003
Posts: 7
deleted_1 is an unknown quantity at this point
I found this, but I still dont know what the heck to do.

Here is what I found in some help file....


2. When executing my dos program, it closes automatically. How I can change this ?

You can use an input function at the end of you source. The following code is an example for asking the user to press Enter to continue:
CPP / C++ / C Code:
#include <stdlib.h>

int main()
{

system(“PAUSE”);
	return 0;

}


And this is the Hello.cpp file I have.....
CPP / C++ / C Code:
#include <iostream>

int main()
{     /* This is a c-style comment
             and it extends until the closing
             star-slash comment mark */
      std::cout << "Hello World!\n";
      // This c++-style comment ends at the end of the line
      std::cout <<"That comment ended!";
      
      // double slash comments can be alone on a line
      /* as can slash-star comments */
      return 0;

}


What do I do?

Thanks.
  #3  
Old 02-Sep-2003, 02:43
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
You are working in a Windows world. Double-clicking an executable you've made runs it in a command prompt (because it's a simple app, which writes to cout only), but if it finishes, Windows closes it.

What you've to do is work in a DOS world. Open a DOS prompt, cd to the directory the executable is held, and type it's filename there. Then you'll see it's output on screen, and it won't disappear.

What's been suggested in the help page you read, is to force the program to wait for input - the puase() function waits for a keypress - before the program will quit - and Windows will close the DOS prompt.

GF
  #4  
Old 02-Sep-2003, 10:04
deleted_1 deleted_1 is offline
New Member
 
Join Date: Sep 2003
Posts: 7
deleted_1 is an unknown quantity at this point
Hey! Thanks for your help!

I did it with the pause function... Is that OK?

And also, will this book really teach me how to be a good programmer?

Thanks.
  #5  
Old 02-Sep-2003, 11:06
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
Whatever does the job for you!

Hate to sound like a dodgy guru (I am NOT a guru), but experience will make you a good programmer.

When you become experienced, look up books on Data Structures & Algorithms, which will intorduce you to new & clever ways of solving problems.

GF
  #6  
Old 02-Sep-2003, 11:20
deleted_1 deleted_1 is offline
New Member
 
Join Date: Sep 2003
Posts: 7
deleted_1 is an unknown quantity at this point
Alright thanks. I'm only on hour 4 in that book right now and it's getting really hard for me to understand.

Can you just give me some examples of programs I will be able to write after I learn C++?

Thanks.
  #7  
Old 03-Sep-2003, 02:27
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
Hmmm, examples? Well imagine any computer program you use. In theory, you'd be able (with a lot of work) to write that.

After I did my course in C++ programming & programming theory, I could write a simple database program, taking very simple SQL statements.

I could make a high precision calculator program. We even created our own programming language - we coded a parser, like PHP.

I've not used any Visual C++ tools, I stick with a gcc compiler. I prefer making programs that do what I want, instead of looking pretty.

GF
  #8  
Old 03-Sep-2003, 09:29
deleted_1 deleted_1 is offline
New Member
 
Join Date: Sep 2003
Posts: 7
deleted_1 is an unknown quantity at this point
Thanks. So what would I have to learn to "make them look pretty"? Im just trying to get some info here. I just want to see whats its all about.
  #9  
Old 03-Sep-2003, 09:39
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
I'm unsure about that book, I don't think it goes into GUI design.

There are programs out there, like Microsoft Visual C++ which contains a WYSIWYG interface design, and allows you to write the code which interacts with these.

So you can make a professional progra, with toolbars, buttons, dialogas and hopefully, with your work, some good functionality.

There are plenty of books out there which go into C++ with GUIs, so surf around.

GF
  #10  
Old 03-Sep-2003, 09:56
deleted_1 deleted_1 is offline
New Member
 
Join Date: Sep 2003
Posts: 7
deleted_1 is an unknown quantity at this point
Yes I will. I just need to see how this book goes first though. I guess pretty much when you know this book inside out you’re considered a novice and it’s already been about 1/2 a week and I just finished hour 6 which completes Part I, named "Introducing C++"

I mean I know its going to be tough, I didn’t even understand a lot of stuff in these first 6 hours so now I need to go back to hour 1 and start all over again to read part I a second time before I get into Part II and hopefully I will know exactly what is going on... if not I guess I'll need to try a third time
 
 

Recent GIDBlogToyota - 2008 September Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Payroll program arek C Programming Language 0 23-Sep-2003 18:20

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:46.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.