Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Random C++ Console Problem
New Posts  All Forums:Forum Nav:

Random C++ Console Problem

post #1 of 11
Thread Starter 
Hello World Application! You all know it, any retard can do it. But not me! I start a new project, "WIN32 Console Application". Compiled and ran and it pops up with the console box and then it disappears straight away.

Code:
// testing.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
cout << "Hello World!";
return 0;
}
I'm kinda new and im wondering if i've set something up wrong. I'm almost certain i've got the right code. I've tried many different ways of setting it up and nothing works. I've copied the code straight from a C++ tutorial and the error still pops up.

I'm using Visual C++ 2008 Express on Windows 7 64bit.

Many thanks to anyone that can help.
Impulss
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 2600k ASROCK Z77 Extreme 6 Gigabyte GTX570 12GB Ripjaws CL7 (2x 2GB, 2x 4GB) 
Hard DriveCoolingOSMonitor
120GB OCZ Vertex II + Data XSPC RASA RX360 Windows 7 Ultimate N 64bit 24" Samsung 1200p 
KeyboardPowerCaseMouse
Microsoft X8 800w Tagen Xigmatek Elysium Gigabyte Ghost 
Mouse PadAudioAudio
Cyber Snipa HD595 + AD700 Sound Blaster X-Fi 
  hide details  
Reply
Impulss
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 2600k ASROCK Z77 Extreme 6 Gigabyte GTX570 12GB Ripjaws CL7 (2x 2GB, 2x 4GB) 
Hard DriveCoolingOSMonitor
120GB OCZ Vertex II + Data XSPC RASA RX360 Windows 7 Ultimate N 64bit 24" Samsung 1200p 
KeyboardPowerCaseMouse
Microsoft X8 800w Tagen Xigmatek Elysium Gigabyte Ghost 
Mouse PadAudioAudio
Cyber Snipa HD595 + AD700 Sound Blaster X-Fi 
  hide details  
Reply
post #2 of 11
Try this:

Code:
// testing.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
    cout << "Hello World!";

    system("PAUSE");
    return 0;
}
Personal PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II 720 Gigabyte MA-790X-UD4P MSI GeForce 9800GT 4GB OCZ Reapers DDR2 1150 @ 800 
Hard DriveOSMonitorPower
Seagate Barracude 250gb * 2 Ubuntu 10.04 23" Dell SP2309W (2048x1152) PC Power & Cooling 610 
Case
Antec Three Hundred 
  hide details  
Reply
Personal PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II 720 Gigabyte MA-790X-UD4P MSI GeForce 9800GT 4GB OCZ Reapers DDR2 1150 @ 800 
Hard DriveOSMonitorPower
Seagate Barracude 250gb * 2 Ubuntu 10.04 23" Dell SP2309W (2048x1152) PC Power & Cooling 610 
Case
Antec Three Hundred 
  hide details  
Reply
post #3 of 11
Thread Starter 
OMG I LOVE YOU!

I have to ask though, why is mine different to everyone elses?
Impulss
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 2600k ASROCK Z77 Extreme 6 Gigabyte GTX570 12GB Ripjaws CL7 (2x 2GB, 2x 4GB) 
Hard DriveCoolingOSMonitor
120GB OCZ Vertex II + Data XSPC RASA RX360 Windows 7 Ultimate N 64bit 24" Samsung 1200p 
KeyboardPowerCaseMouse
Microsoft X8 800w Tagen Xigmatek Elysium Gigabyte Ghost 
Mouse PadAudioAudio
Cyber Snipa HD595 + AD700 Sound Blaster X-Fi 
  hide details  
Reply
Impulss
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 2600k ASROCK Z77 Extreme 6 Gigabyte GTX570 12GB Ripjaws CL7 (2x 2GB, 2x 4GB) 
Hard DriveCoolingOSMonitor
120GB OCZ Vertex II + Data XSPC RASA RX360 Windows 7 Ultimate N 64bit 24" Samsung 1200p 
KeyboardPowerCaseMouse
Microsoft X8 800w Tagen Xigmatek Elysium Gigabyte Ghost 
Mouse PadAudioAudio
Cyber Snipa HD595 + AD700 Sound Blaster X-Fi 
  hide details  
Reply
post #4 of 11
The system("PAUSE") line isn't needed on Macs, but Windows compilers need it.
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
post #5 of 11
run it in a command prompt window instead of clicking the exe
it's common for console apps to do this in windows since windows doesn't leave the dos prompt open
Quad
(14 items)
 
HTPC
(13 items)
 
 
CPUMotherboardGraphicsRAM
Q9550 @ 3.2GHz GA-EP45-UD3P EVGA 02G-P4-2670-KR GeForce GTX 670 2GB 8GB total, Kingston HyperX 4GB KHX8500D2K2/4G 
CoolingOSPowerCase
ZALMAN CNPS9900ALED 120mm Win 7 64bit Sunbeam PSU-ECO650-US 650W ATX12V V2.3 80 PLUS Antec Three Hundred 
Mouse
Logitech G500 
CPUGraphicsRAMHard Drive
Intel Core 2 Duo E7300 Wolfdale 2.66GHz MSI N9400GT-MD256 GeForce 9400 GT 256MB Kingston HyperX 2GB (2 x 1GB) Seagate Barracuda 7200.10 ST3750640AS 750GB 
Optical DriveCase
LG GGC-H20L Blu-ray/HD DVD-ROM Shuttle SG33G5B 
  hide details  
Reply
Quad
(14 items)
 
HTPC
(13 items)
 
 
CPUMotherboardGraphicsRAM
Q9550 @ 3.2GHz GA-EP45-UD3P EVGA 02G-P4-2670-KR GeForce GTX 670 2GB 8GB total, Kingston HyperX 4GB KHX8500D2K2/4G 
CoolingOSPowerCase
ZALMAN CNPS9900ALED 120mm Win 7 64bit Sunbeam PSU-ECO650-US 650W ATX12V V2.3 80 PLUS Antec Three Hundred 
Mouse
Logitech G500 
CPUGraphicsRAMHard Drive
Intel Core 2 Duo E7300 Wolfdale 2.66GHz MSI N9400GT-MD256 GeForce 9400 GT 256MB Kingston HyperX 2GB (2 x 1GB) Seagate Barracuda 7200.10 ST3750640AS 750GB 
Optical DriveCase
LG GGC-H20L Blu-ray/HD DVD-ROM Shuttle SG33G5B 
  hide details  
Reply
post #6 of 11
It's bad practice to use system("pause")

I wont bother repeating the reasons why because we've had this exact same thread once this week already ( http://www.overclock.net/t/1246587/c-hello-world ), but the comment about the system call is here (for those who can't be bothered to read the whole thread)
post #7 of 11
Quote:
Originally Posted by Plan9 View Post

It's bad practice to use system("pause")
I wont bother repeating the reasons why because we've had this exact same thread once this week already ( http://www.overclock.net/t/1246587/c-hello-world ), but the comment about the system call is here (for those who can't be bothered to read the whole thread)

You do realise you just bumped a 2 year old thread? headscratch.gif

But thanks for repeating that anyway. biggrin.gif
MacBook Pro 13"
(6 items)
 
 
Desktop
(13 items)
 
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
  hide details  
Reply
MacBook Pro 13"
(6 items)
 
 
Desktop
(13 items)
 
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
  hide details  
Reply
post #8 of 11
Quote:
Originally Posted by {Unregistered} View Post

You do realise you just bumped a 2 year old thread? headscratch.gif
But thanks for repeating that anyway. biggrin.gif

Weird because I could have sworn it showed up as a recent thread.

Is there a chance someone could have made a post before me (thus bumping the thread) then deleted it? If not, then I'm sorry for the epic thread revival. redface.gif
post #9 of 11
Quote:
Originally Posted by Plan9 View Post

Weird because I could have sworn it showed up as a recent thread.
Is there a chance someone could have made a post before me (thus bumping the thread) then deleted it? If not, then I'm sorry for the epic thread revival. redface.gif

Only mods can delete posts as far as I know. But it's good that you posted this anyway. Lots of people still use system(''pause'').
MacBook Pro 13"
(6 items)
 
 
Desktop
(13 items)
 
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
  hide details  
Reply
MacBook Pro 13"
(6 items)
 
 
Desktop
(13 items)
 
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
  hide details  
Reply
post #10 of 11

Yeah, there was a spam post  that was deleted just before you replied. :P

Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Random C++ Console Problem