Page Index Toggle Pages: 1 [2]  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) C++ (Read 6420 times)
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: C++
Reply #15 - Apr 15th, 2007 at 4:42am
Print Post Print Post  
It sounds like the microsoft "console window". This is a window that appears when running MS programs that write output to "standard output" and have console mode enabled. The console window will remain on the screen for as long as your program continues to run. So what you are probably seeing is your program writing some text to "standard output" and then exiting. To keep the window around longer you need to keep your program running longer. There are two typical ways to do that. One is you could simply force your program to wait a while, using using a Sleep command (Sleep(milliseconds) or sleep(seconds)) or put in a busy loop. A busy loop simply runs up an integer doing nothing: for(n = 0;n < 100000000;n++); The other thing you could do is get some blocking input going, which sounds like what the book wants with "hit any key to continue". In C this would be something like c = fgetc(stdin) or fgets(buf, 255, stdin).

I am very happy to hear that you are actively seeking out new things to learn. I hope that C and C++ are to your liking. If you have already picked up Pascal, C should follow somewhat similarly. They are both really in the same family, though C is lower level and relies much more heavily on operators than does Pascal. The biggest differences might be that C is not as strict about structure and has pointers. C++, on the other hand, is quite different from Pascal in that it is nominally an "object orientated" language. It introduces classes, overides, templates, and much else that are not in straight procedural languages like C and Pascal.

It sounds like your book is headed towards Windows programming (in that it provides MS Visual C++). You may want to keep going in that direction, but it will be harder to help you in that MS does things very differently than a normal C/C++ compiler and does not rigorously stick with standards (not K&R, Stroustrup, ANSI, or POSIX). You might consider some of the free compilers available for Windows, such as Digital Mars C/C++. Or, use the C/C++ compiler that is the defacto standard on Linux: gcc and g++ - the gnu compiler. Using a command line driven compiler will eliminate the need to worry about Window's console window and other oddities only associated with MS programs and programming environments.

Even when we build Sesame on Windows, we don't use the Visual environment. We use the MS compiler from the command line. That allows us to write debug out to the command line window that invoked the program, without having the program opening its own "concole window". It also is, in my opinion, a more reasonable environment than MS's IDE. I'm not sure how comfortable you are with the command line in Windows or in Linux, but I much prefer to have multiple command line windows open, than to mess around with pulldowns and dialog boxes.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: C++
Reply #16 - Apr 15th, 2007 at 6:26am
Print Post Print Post  
ProudPoppy, check this out: http://groups.google.com/group/microsoft.public.win32.programmer.gdi/browse_thre...

It suggests adding a Pause or GetChar at the end of the code, forcing a pause for input.

system("PAUSE");

OR

getchar()
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: C++
Reply #17 - Apr 15th, 2007 at 4:26pm
Print Post Print Post  
Thanks Mark & Bob, I'm using a c++ compiler from www.bloodshed.net, along with the one from the book.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: C++
Reply #18 - Apr 15th, 2007 at 4:30pm
Print Post Print Post  
proudpoppy wrote on Apr 15th, 2007 at 4:26pm:
Thanks Mark & Bob, I'm using a c++ compiler from www.bloodshed.net, along with the one from the book.


My, what a gruesome sounding URL for such a benign appearing website.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: C++
Reply #19 - Apr 15th, 2007 at 4:59pm
Print Post Print Post  
In any case, if you run a program that writes to standard output, from a command line (instead of from an icon or menu, etc...), it shouldn't have to open a console window. It will simply print in the command line window from which it was opened. So no need for catching keys or causing delays.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send Topic Send Topic Print Print