Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Subject: c++ newbie

Original Message
Name: dugie
Date: May 2, 2008 at 07:39:28 Pacific
Subject: c++ newbie
OS: me
CPU/Ram: 256
Model/Manufacturer: t1842
Comment:
hi to all,im very much interested studying c++ but my problem is when i compile and run the sample code like the "simple hello world" program my compiler compiles the code but i cannot see the output or the result its just a blink then gone, pls help me, im just a newbie in this course. im using dev c++ compiler..

Report Offensive Message For Removal

Response Number 1
Name: boaster
Date: May 2, 2008 at 09:38:13 Pacific
Subject: c++ newbie
Reply: (edit)
It sounds like what's happening is that your program is running in a DOS window, which closes as soon as the program is done running.

At the top of your code add

#include <dos.h>

After your "simple hello world" code add

sleep(5);

THis adds a five second delay, which should be long enough or you to see the text displayed.


Report Offensive Follow Up For Removal

Response Number 2
Name: Razor2.3
Date: May 2, 2008 at 14:12:27 Pacific
Subject: c++ newbie
Reply: (edit)
The default C++ console template for Dev-C++ includes the line system("SLEEP"); just before the return EXIT_SUCCESS; for a reason. Try adding the line before your return statement.

Report Offensive Follow Up For Removal

Response Number 3
Name: dugie
Date: May 3, 2008 at 09:06:50 Pacific
Subject: c++ newbie
Reply: (edit)
thanks for the reply bros. but it did not work for this sample code.. pls try this.


#include <iostream>
#include <stdlib.h>
#include <windows.h>
#include <dos.h>
#include <conio.h>

using namespace std;
int main()


{
SetConsoleTitle("Console Colors");
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord = {104, 37};
SMALL_RECT rec = {0, 0, 0, 0};
SetConsoleScreenBufferSize(hout, coord);
rec.Right = coord.X -1;
rec.Bottom = coord.Y -1;
SetConsoleWindowInfo(hout,TRUE,&rec);

for(int i = 0; i < 256;i++)


{
SetConsoleTextAttribute(hout,i);
cout.width(9); cout<<"text col";
cout.width(4);cout<<i;
}

COORD coord1 = {30, 34};
SetConsoleCursorPosition(hout, coord1);
SetConsoleTextAttribute(hout,249);


return 0;
}
thanks again sir...


Report Offensive Follow Up For Removal

Response Number 4
Name: Razor2.3
Date: May 3, 2008 at 13:51:57 Pacific
Subject: c++ newbie
Reply: (edit)
Do you know what I'm not seeing in there? system("PAUSE");

Report Offensive Follow Up For Removal

Response Number 5
Name: dugie
Date: May 8, 2008 at 01:09:36 Pacific
Subject: c++ newbie
Reply: (edit)
how sir?im just a beginner pls. help... ty

Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: c++ newbie

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software



Version Tracker Pro
Keep your software current and secure, effortlessly

Click Here for a Free Scan

Driver Agent
Automatically find the latest drivers for your computer.
Click Here for a Free Scan



The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC