BleepingComputer.com: C++ Problem

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

C++ Problem It won't run

#1 User is offline   TelMeDragon 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 80
  • Joined: 10-January 07

Posted 16 February 2008 - 01:43 AM

Ok well I decided to learn C++, and after doing a "Hello World" Basic run-through (and an attempt at a fahreneit to Celsius converter). I have failed miserably.

The converter didn't work because of some errors, I'm not sure where, i copied it straight off the book i bought.

The hello world didn't work because the program won't run. I compiled it and found the .exe and double clicked it but all that pops up is a command prompt for a second and then it disappears with ntohing else.

I am using Dev-C++

Does anyone know what's wrong?
Posted Image

#2 User is offline   tswsl1989 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 260
  • Joined: 11-June 07
  • Gender:Male
  • Location:Cymru/Wales

Posted 16 February 2008 - 07:27 AM

The hellow world one sounds like it's worked.
Try opening a command prompt, then running the hello world program from there.

C++ examples can often (even though they shouldn't) be compiler specific.
Try searching the net for Dev-C++ Tutorials\examples.

From another C++ learner, I hope that helps,
Tom

Tswsl1989
Duct tape is like the force. It has a light side, a dark side, and it holds the universe together

#3 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,604
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 16 February 2008 - 08:33 AM

C++ is not compiler specific. :thumbsup:

However, tswsl1989 is correct that the program probably ran fine. If the command window opened and closed, then it worked. It only takes about a tenth of a second to run a "hello world" program. As was stated, drop to a command line prompt, and execute your code from there.
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#4 User is offline   TelMeDragon 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 80
  • Joined: 10-January 07

Posted 16 February 2008 - 12:54 PM

Ok thank you for your replies, and I have found my problem after digging through various codes from tutorials. Thank you once again
Posted Image

#5 User is offline   danbrownlow 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 99
  • Joined: 05-March 07
  • Gender:Male

Posted 22 February 2008 - 08:53 AM

Also, when learning I realised (I'm english.. I'm not spelling wrong :thumbsup:) that before returning, if you type System("pause"); then it would halt the program so you could actually see what was happening =]

Dan

#6 User is offline   Deemo Diablo 

  • New Member
  • Pip
  • Find Topics
  • Group: Members
  • Posts: 12
  • Joined: 23-March 08
  • Gender:Male
  • Location:76704

Posted 23 March 2008 - 05:38 AM

If it's not too late I would like to add that entering:

char response;
std::cin >> response;



before return 0; would let you see the results of your program by closing the program only when a random character is pressed followed by the enter key upon completion of said program.

This post has been edited by Deemo Diablo: 23 March 2008 - 05:41 AM


#7 User is offline   Billy O'Neal 

  • Bleepin Engineer GRADUATE
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Malware Response Instructor
  • Posts: 10,391
  • Joined: 17-January 08
  • Gender:Male
  • Location:Cleveland, Ohio

Posted 26 March 2008 - 09:08 PM

View PostDeemo Diablo, on Mar 23 2008, 06:38 AM, said:

If it's not too late I would like to add that entering:

char response;
std::cin >> response;



before return 0; would let you see the results of your program by closing the program only when a random character is pressed followed by the enter key upon completion of said program.

Careful! Dont want buffer overruns, now do we?

Billy3

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users