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++ Problem


  • Please log in to reply
6 replies to this topic

#1 TelMeDragon

TelMeDragon

  • Members
  • 80 posts
  • OFFLINE
  •  
  • Local time:04:32 AM

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

BC AdBot (Login to Remove)

 


#2 tswsl1989

tswsl1989

  • Members
  • 260 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Cymru/Wales
  • Local time:10:32 AM

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 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:32 AM

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.

#4 TelMeDragon

TelMeDragon
  • Topic Starter

  • Members
  • 80 posts
  • OFFLINE
  •  
  • Local time:04:32 AM

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 Guest_danbrownlow_*

Guest_danbrownlow_*

  • Guests
  • OFFLINE
  •  

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 Deemo Diablo

Deemo Diablo

  • Members
  • 12 posts
  • OFFLINE
  •  
  • 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.

Edited by Deemo Diablo, 23 March 2008 - 05:41 AM.


#7 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:04:32 AM

Posted 26 March 2008 - 09:08 PM

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
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users