Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

C++


  • Please log in to reply
5 replies to this topic

#1 TelMeDragon

TelMeDragon

  • Members
  • 80 posts
  • OFFLINE
  •  
  • Local time:11:41 PM

Posted 10 August 2007 - 08:51 PM

I just started C++ and have no pre-programming knowledge (except from some web coding) and I would like to ask what am I missing?
I downloaded Dev-C++ and made a program and then created an .exe but then it won't run. The program is supposed to say Hello World.
Posted Image

BC AdBot (Login to Remove)

 


#2 jhsmurray

jhsmurray

  • Members
  • 383 posts
  • OFFLINE
  •  
  • Location:6,378 km above the Earth's core
  • Local time:12:41 AM

Posted 11 August 2007 - 06:33 AM

I'm not claiming to be a programming pro, but this is what I have experienced when working with C++. When creating console programs, you need to code it so that the window stays open, otherwise when the routine is finished it closes itself. With a small program like "Hello World" it runs so fast it can almost instantaneous. Have a look at the faqs in the devshed site for some hints with this.

If you are referring to an actual error message, post it here and some people more experienced than I might be able to help. :thumbsup:

Acer Aspire 5732z
OS: Windows 7 Ultimate
Processor: Intel Pentium III Xeon, 2200 MHz
RAM: 3 GB
Display: Mobile Intel GMA 4500M

#3 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:10:41 PM

Posted 11 August 2007 - 11:57 AM

Open a command prompt and run the executable. As jhsmurray already mentioned, a tiny executable like that will run so fast, the command prompt window will open, the program will execute, and the command prompt will close faster than you can blink.

#4 TelMeDragon

TelMeDragon
  • Topic Starter

  • Members
  • 80 posts
  • OFFLINE
  •  
  • Local time:11:41 PM

Posted 12 August 2007 - 12:03 AM

// my first program in C++

#include <iostream>
using namespace std;

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

This is the code i was instructed to put down, would it result in a quick appearance and disappearance?
Posted Image

#5 LilPinoyBoy

LilPinoyBoy

  • Members
  • 31 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Oakland, CA
  • Local time:09:41 PM

Posted 12 August 2007 - 02:22 AM

I'm merely a beginner as well but here is what I've learned from my book, I've been reading.

Add: system("PAUSE");

right above return 0;

#include <iostream>

using namespace std;

int main()
{
   cout << "Hello World!"<< endl;
   cin.get();
   system("PAUSE");
   return 0;
}

I may be wrong, but I tried it a few days ago and it worked.

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:10:41 PM

Posted 12 August 2007 - 09:57 AM

would it result in a quick appearance and disappearance


Well, yes. A window doesn't appear by magic. If you want it to be in a window, you have to program the window too. You could add a pause as suggested, or just run it from the command line after you compile the executable.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users