New Posts  All Forums:Forum Nav:

C++ console closes!

post #1 of 12
Thread Starter 
I just started trying to get back to c++ and for some reason no matter what I try nothing but cin works to pause this. I can post my full code if needed.

Here is a sample.
Code:
else {
string sUser;
ifstream config("config.txt");

while(config.good()){
getline(config, sUser);
cout << "hi " << sUser << endl;
}
}
Performance 1
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 950 @ 4.4GHz Asus P6X58D-E 2x eVGA GTX 470 SLi G.skill Ripjaws 6GB @ 1603MHz 
Hard DriveCoolingOSMonitor
3x Samsung f3 Heatkiller 3.0 (Feser 480) windows 7 64-Bit 2x LG 20" lcds 
KeyboardPowerCaseMouse
Microsoft (G19 dead) Thermaltake 850w Thermaltake Armor logitech mx-518 
Mouse Pad
Puppy dog mouse pad 
  hide details  
Reply
Performance 1
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 950 @ 4.4GHz Asus P6X58D-E 2x eVGA GTX 470 SLi G.skill Ripjaws 6GB @ 1603MHz 
Hard DriveCoolingOSMonitor
3x Samsung f3 Heatkiller 3.0 (Feser 480) windows 7 64-Bit 2x LG 20" lcds 
KeyboardPowerCaseMouse
Microsoft (G19 dead) Thermaltake 850w Thermaltake Armor logitech mx-518 
Mouse Pad
Puppy dog mouse pad 
  hide details  
Reply
post #2 of 12
system("pause");
Waiting on X399
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II B57 @ X4 3.9 Gigabyte 790FXTA-UD5 Sapphire Radeon 290 8 GB G.Skill 2133 
Hard DriveCoolingOSKeyboard
250 GB 840 EVO Noctua NH-D14 Windows 10 Logitech K350 
PowerCaseMouseMouse Pad
Seasonic x750 Corsair 600T Logitech G100s Razer Goliathus Speed 
Audio
Plantronics Gamecom 788 
  hide details  
Reply
Waiting on X399
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II B57 @ X4 3.9 Gigabyte 790FXTA-UD5 Sapphire Radeon 290 8 GB G.Skill 2133 
Hard DriveCoolingOSKeyboard
250 GB 840 EVO Noctua NH-D14 Windows 10 Logitech K350 
PowerCaseMouseMouse Pad
Seasonic x750 Corsair 600T Logitech G100s Razer Goliathus Speed 
Audio
Plantronics Gamecom 788 
  hide details  
Reply
post #3 of 12
Thread Starter 
Quote:
Originally Posted by beers View Post
system("pause");
From what I have heard that is a terrible security hole.
Performance 1
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 950 @ 4.4GHz Asus P6X58D-E 2x eVGA GTX 470 SLi G.skill Ripjaws 6GB @ 1603MHz 
Hard DriveCoolingOSMonitor
3x Samsung f3 Heatkiller 3.0 (Feser 480) windows 7 64-Bit 2x LG 20" lcds 
KeyboardPowerCaseMouse
Microsoft (G19 dead) Thermaltake 850w Thermaltake Armor logitech mx-518 
Mouse Pad
Puppy dog mouse pad 
  hide details  
Reply
Performance 1
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 950 @ 4.4GHz Asus P6X58D-E 2x eVGA GTX 470 SLi G.skill Ripjaws 6GB @ 1603MHz 
Hard DriveCoolingOSMonitor
3x Samsung f3 Heatkiller 3.0 (Feser 480) windows 7 64-Bit 2x LG 20" lcds 
KeyboardPowerCaseMouse
Microsoft (G19 dead) Thermaltake 850w Thermaltake Armor logitech mx-518 
Mouse Pad
Puppy dog mouse pad 
  hide details  
Reply
post #4 of 12
or getchar()

system("pause") makes some antivirus programs go crazy.
X-Caliber
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Quad Q8300 @3.0 Ghz Gigabyte EP43 UD3L ATI Radeon HD3850 512MB 800/950 4x1 GB 800 mhz DDR2 (Dual Channel) 
Hard DriveOptical DriveOSMonitor
160 Hitachi HDD LG Super-Multi Drive with SecurDisc Windows 7 - Ultimate (x86) Samsung SyncMaster 2043SWX 20" 1600x900 
KeyboardPowerCaseMouse
Logitech G15 Gaming Keyboard rev. 2 460 watt Coolermaster Coolermaster Elite Razer Deathadder 
Mouse Pad
Steelseries QcK 
  hide details  
Reply
X-Caliber
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Quad Q8300 @3.0 Ghz Gigabyte EP43 UD3L ATI Radeon HD3850 512MB 800/950 4x1 GB 800 mhz DDR2 (Dual Channel) 
Hard DriveOptical DriveOSMonitor
160 Hitachi HDD LG Super-Multi Drive with SecurDisc Windows 7 - Ultimate (x86) Samsung SyncMaster 2043SWX 20" 1600x900 
KeyboardPowerCaseMouse
Logitech G15 Gaming Keyboard rev. 2 460 watt Coolermaster Coolermaster Elite Razer Deathadder 
Mouse Pad
Steelseries QcK 
  hide details  
Reply
post #5 of 12
Quote:
Originally Posted by fastsite View Post
From what I have heard that is a terrible security hole.
If you're using depreciated headers like iostream you aren't going to make an application where it really matters.
Waiting on X399
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II B57 @ X4 3.9 Gigabyte 790FXTA-UD5 Sapphire Radeon 290 8 GB G.Skill 2133 
Hard DriveCoolingOSKeyboard
250 GB 840 EVO Noctua NH-D14 Windows 10 Logitech K350 
PowerCaseMouseMouse Pad
Seasonic x750 Corsair 600T Logitech G100s Razer Goliathus Speed 
Audio
Plantronics Gamecom 788 
  hide details  
Reply
Waiting on X399
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II B57 @ X4 3.9 Gigabyte 790FXTA-UD5 Sapphire Radeon 290 8 GB G.Skill 2133 
Hard DriveCoolingOSKeyboard
250 GB 840 EVO Noctua NH-D14 Windows 10 Logitech K350 
PowerCaseMouseMouse Pad
Seasonic x750 Corsair 600T Logitech G100s Razer Goliathus Speed 
Audio
Plantronics Gamecom 788 
  hide details  
Reply
post #6 of 12
Thread Starter 
Quote:
Originally Posted by Darkknight512 View Post
or getchar()

system("pause") makes some antivirus programs go crazy.
I tried getchar() and it doesn't work on this one.

Quote:
Originally Posted by beers View Post
If you're using depreciated headers like iostream you aren't going to make an application where it really matters.
As Dark said some anti-virus programs get mad with it.
Performance 1
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 950 @ 4.4GHz Asus P6X58D-E 2x eVGA GTX 470 SLi G.skill Ripjaws 6GB @ 1603MHz 
Hard DriveCoolingOSMonitor
3x Samsung f3 Heatkiller 3.0 (Feser 480) windows 7 64-Bit 2x LG 20" lcds 
KeyboardPowerCaseMouse
Microsoft (G19 dead) Thermaltake 850w Thermaltake Armor logitech mx-518 
Mouse Pad
Puppy dog mouse pad 
  hide details  
Reply
Performance 1
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 950 @ 4.4GHz Asus P6X58D-E 2x eVGA GTX 470 SLi G.skill Ripjaws 6GB @ 1603MHz 
Hard DriveCoolingOSMonitor
3x Samsung f3 Heatkiller 3.0 (Feser 480) windows 7 64-Bit 2x LG 20" lcds 
KeyboardPowerCaseMouse
Microsoft (G19 dead) Thermaltake 850w Thermaltake Armor logitech mx-518 
Mouse Pad
Puppy dog mouse pad 
  hide details  
Reply
post #7 of 12
Does this work?

cin.get();
X-Caliber
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Quad Q8300 @3.0 Ghz Gigabyte EP43 UD3L ATI Radeon HD3850 512MB 800/950 4x1 GB 800 mhz DDR2 (Dual Channel) 
Hard DriveOptical DriveOSMonitor
160 Hitachi HDD LG Super-Multi Drive with SecurDisc Windows 7 - Ultimate (x86) Samsung SyncMaster 2043SWX 20" 1600x900 
KeyboardPowerCaseMouse
Logitech G15 Gaming Keyboard rev. 2 460 watt Coolermaster Coolermaster Elite Razer Deathadder 
Mouse Pad
Steelseries QcK 
  hide details  
Reply
X-Caliber
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Quad Q8300 @3.0 Ghz Gigabyte EP43 UD3L ATI Radeon HD3850 512MB 800/950 4x1 GB 800 mhz DDR2 (Dual Channel) 
Hard DriveOptical DriveOSMonitor
160 Hitachi HDD LG Super-Multi Drive with SecurDisc Windows 7 - Ultimate (x86) Samsung SyncMaster 2043SWX 20" 1600x900 
KeyboardPowerCaseMouse
Logitech G15 Gaming Keyboard rev. 2 460 watt Coolermaster Coolermaster Elite Razer Deathadder 
Mouse Pad
Steelseries QcK 
  hide details  
Reply
post #8 of 12
Thread Starter 
Quote:
Originally Posted by Darkknight512 View Post
Does this work?

cin.get();
nope
Performance 1
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 950 @ 4.4GHz Asus P6X58D-E 2x eVGA GTX 470 SLi G.skill Ripjaws 6GB @ 1603MHz 
Hard DriveCoolingOSMonitor
3x Samsung f3 Heatkiller 3.0 (Feser 480) windows 7 64-Bit 2x LG 20" lcds 
KeyboardPowerCaseMouse
Microsoft (G19 dead) Thermaltake 850w Thermaltake Armor logitech mx-518 
Mouse Pad
Puppy dog mouse pad 
  hide details  
Reply
Performance 1
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 950 @ 4.4GHz Asus P6X58D-E 2x eVGA GTX 470 SLi G.skill Ripjaws 6GB @ 1603MHz 
Hard DriveCoolingOSMonitor
3x Samsung f3 Heatkiller 3.0 (Feser 480) windows 7 64-Bit 2x LG 20" lcds 
KeyboardPowerCaseMouse
Microsoft (G19 dead) Thermaltake 850w Thermaltake Armor logitech mx-518 
Mouse Pad
Puppy dog mouse pad 
  hide details  
Reply
post #9 of 12
Quote:
Originally Posted by fastsite View Post
nope
You're doing it wrong.

Code:
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
while(true) {
cout << "Press Any Key To Continue"; cin.get();
} return 0;
}
Compiles and runs exactly as intended. The program will pause until any key is pressed.
    
CPUMotherboardGraphicsRAM
Core i5 4670k ASUS Maximus VI Gene Gigabyte GTX 460 1GB Kingston Hyper-X 
Hard DriveHard DriveHard DriveHard Drive
Samsung 830 OCZ Vertex 3 WD6401AALS WD5000AAKS 
CoolingOSMonitorMonitor
Noctua NH-D14 elementary OS Dell Ultrasharp U2312HM LG W2442PA-BF 
KeyboardPowerCaseMouse
Microsoft Sidewinder X4 Corsair HX750W Corsair Graphite 600T Logitech G700 
Audio
ASUS Xonar DG 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Core i5 4670k ASUS Maximus VI Gene Gigabyte GTX 460 1GB Kingston Hyper-X 
Hard DriveHard DriveHard DriveHard Drive
Samsung 830 OCZ Vertex 3 WD6401AALS WD5000AAKS 
CoolingOSMonitorMonitor
Noctua NH-D14 elementary OS Dell Ultrasharp U2312HM LG W2442PA-BF 
KeyboardPowerCaseMouse
Microsoft Sidewinder X4 Corsair HX750W Corsair Graphite 600T Logitech G700 
Audio
ASUS Xonar DG 
  hide details  
Reply
post #10 of 12
Quote:
Originally Posted by beers View Post
If you're using depreciated headers like iostream you aren't going to make an application where it really matters.
This.
Also, run the executable from command line, you will not need a pause:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\\Users\\cdolphin>cd CPP\\HelloWorld\\

C:\\Users\\cdolphin\\CPP\\HelloWorld>bin\\Debug\\H elloWorld.exe
Hello world!

Main.cpp:
Code:
#include <iostream>

using namespace std;

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

Edited by wcdolphin - 3/18/11 at 5:03pm
For sale
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-920 Asus P6T Deluxe Asus GTX460 TOP 768mb G Skill ECO 1600 CAS7 1.35V 
Hard DriveOptical DriveOSMonitor
2x Vertex 60 GB raid[0] Asus DVDRW W7,Ubuntu 2 xAsus VH236H 
KeyboardPowerCaseMouse Pad
Razer Ultra X3 1000W HAF 932 My Desk 
  hide details  
Reply
For sale
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-920 Asus P6T Deluxe Asus GTX460 TOP 768mb G Skill ECO 1600 CAS7 1.35V 
Hard DriveOptical DriveOSMonitor
2x Vertex 60 GB raid[0] Asus DVDRW W7,Ubuntu 2 xAsus VH236H 
KeyboardPowerCaseMouse Pad
Razer Ultra X3 1000W HAF 932 My Desk 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming