This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes C / C++ and the fly likes c++ without fear HELP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "c++ without fear HELP" Watch "c++ without fear HELP" New topic
Author

c++ without fear HELP

daniel bailie
Greenhorn

Joined: Oct 26, 2011
Posts: 4

hi, i think i'm doing something stupid but i can't see what i'm doing wrong, heres my problem

on example 1.1 of C++ without fear, edition 2

i'm using dev-c++ 4.9.8.0 and i do everthing it asks me but when i add a new project, the code in main.cpp does'nt match what the book says:

what i'm getting:


what it should be


i try to continue by adding the line " cout << "Never fear, C++ is here!"; " in between int main and system("PAUSE"), like the book tells me to but when the program is complied it doesn't work


Wise men don't require assistance, Fools don't accept it. - someone(i forgot their name)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
I would have thought both code fragments were valid and equivalent to each other. The compiler is indifferent to whether the { is on a line by itself or not. Some people (myself included) think {s and }s should be on a line to themselves. It may be that your IDE has been set up to move { and } to lines by themselves. Can’t remember that from dev-c++, which I haven’t used for a long time, but I liked it when I used it.
system("PAUSE"); is unnecessary in some locations, and you may have to remove it if you are running from the command line.

It does, however, matter whether the { is before or after bits of code. So if you have got the cout line on the wrong side of a {. or even lost the { altogether, you will introduce an error into the code.

And welcome to the Ranch
daniel bailie
Greenhorn

Joined: Oct 26, 2011
Posts: 4

first off, sorry, there wasn't actually a problem at all. it was all a result of my brain not being able to read at 2 in the morning. the output of the program was "Never fear, C++ is here!Press any key to continue . . .", and i only read the press any key part., i completely fail sometimes

and thank you it very nice to be here
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
You’re welcome
I had presumed the one missing ; was caused by your copying wrongly. Always use copy-and-paste.
There is some way to print a new line; you follow the "C++ is brilliant" bit by << and something else ;

Try std::endl or endl for end line. I found that here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: c++ without fear HELP
 
Similar Threads
how to cast array of bytes into array of int
FileNotFoundException
beginner problem
Help with c++ and cmd.exe
java passing variables by reference?