Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help!
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nemisis652




PostPosted: Thu Apr 30, 2009 6:11 pm   Post subject: Help!

Hey,
im very new to C++ and have taken measures to aquire a copy of "C++ for Dummies" which comes with a CD-ROM with a copy of Dev-C++ and some source code in the book, however i dont have that CD so i am forced to write the code in the book out by hand and into my downloaded Beta Copy of Dev-C++ (version 5 i believe)

well my problem is i am running into errors when compiling the code I'm inputting into the Dev and i am not sure what the problem is, because i am inputting the code exactly as is. So my two thoughts are: 1) im missing something that the CDROM has that the book isnt showing 2) The Dev im running is bugged

The errors im getting are with the cout and cin statements and its telling me that they are undeclared.
this is my code:

c++:
//BoolTest - compare variables input from the
//           keyboard and store the results off
//           into a logical variable
#include <cstdio>
#include <cstdlib>
#include <iostream>

int main(int nNumberofArgs, char* pszArgs[])
{
//set output format for bool variables
//to true and false instead of 1 and 0
cout.setf (cout.boolalpha);
   
//initialize two arguments
int nArg1;
cout << "Input Value 1: ";
cin >> nArg1;
   
int nArg2;
cout << "Input Value 2: ";
cin >> nArg2;
   
bool b;
b = nArg1 == nArg2;
   
cout << "the statement, " << nArg1
       << " equals "           << nArg2
       << " is "                  << b
       << end1;
         
system("PAUSE");
return 0;
}   



im sorry in advance if im posting my question wrong, or posting my code wrong. Not only am i new at C++ but im new at Compsci.
Any help would be greatly appreciated as i need to learn this as fast as possible!
Thanks! Smile


Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="cpp"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Apr 30, 2009 6:23 pm   Post subject: RE:Help!

Loving that thread title, nemesis. Very descriptive.
nemisis652




PostPosted: Thu Apr 30, 2009 6:26 pm   Post subject: RE:Help!

lol i just thought it would catch some attention, i suppose it worked. Razz

Sorry though! theres always next time.
Insectoid




PostPosted: Thu Apr 30, 2009 6:49 pm   Post subject: RE:Help!

It didn't work. There are hundreds of posts with this or similar names every year. Be creative, and think a bit. Am I the first to post something about help?

Anywho, it looks like you're putting effort into this and while I can't help you (don't know the first thing about C++), I'm sure somebody will.
zero-impact




PostPosted: Thu Apr 30, 2009 6:51 pm   Post subject: RE:Help!

The problem is you need to do it like this
code:
std::cout << "words";
std::cin >> variable;


otherwise add

code:
using namespace std;

Just after your #includes.
nemisis652




PostPosted: Thu Apr 30, 2009 7:13 pm   Post subject: RE:Help!

okay thank you so much, it cleared up my problems but im having one more and its come up a few times in other programs, maybe you guys can help me out.

in the book its telling me to use a function 'end1', while the book says that it creates a new-line, my version of Dev-C++ says its undeclared. As i previously said im extremely new so im just guessing, but would it work to declare end1 a '/n' to make it a new line, or does that only work in strings?

p.s. insectoid, your right about the hastiness about my post, but im really putting my all into it and i guess i didnt lurk the forum enough to really get a handle on how things work around here. Not only am i learning C++ but im learning the nuances of this forum and i look forward to being a (hopefully) skilled contributing member to this community.
saltpro15




PostPosted: Thu Apr 30, 2009 7:18 pm   Post subject: RE:Help!

way to kiss ass Wink and you're reading it wrong, its endl, not end1, it looks like this
c++:

cout << "Hello!" << endl;
zero-impact




PostPosted: Thu Apr 30, 2009 7:19 pm   Post subject: RE:Help!

That "1" you are seeing is actually an "l" (lowercase L).

So it would be:
[code]std::endl[\code]
Notice the use of "std::" again.
Sponsor
Sponsor
Sponsor
sponsor
nemisis652




PostPosted: Thu Apr 30, 2009 7:20 pm   Post subject: RE:Help!

shit, i have literally been doing that this whole time :O haha
thanks!
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: