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

Username:   Password: 
 RegisterRegister   
 Compiolation difficulties of code, cannot understand where I am going wrong...
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jaymon333




PostPosted: Fri Oct 12, 2007 8:21 pm   Post subject: Compiolation difficulties of code, cannot understand where I am going wrong...

Im just trying to learn C++ and was starting on some very basic code. Here is what I was working on:

#include <iostream>

using namespace std;

int main()

{
cout"Hey you! I am still alive! The World's End!!\n"
cin.get();
}






My compiler is giving me a message, apparently I wrote something wrong on line 9 that is "cin.get();"

It gives the message saying 'cout' undeclared (first use this function)


I am also confused as to why it is talking about 'cout' when that is on the eigth line.

Can anyone help. I'm sure you will all laugh because this is real basic script but im trying to teach myself C++, it's interesting.
Sponsor
Sponsor
Sponsor
sponsor
Euphoracle




PostPosted: Fri Oct 12, 2007 8:23 pm   Post subject: RE:Compiolation difficulties of code, cannot understand where I am going wrong...

cout has it's own special way of doing things, and the beginner doesn't usually get it. You'll need to shift things with cout, even though it doesn't actually shift it. :\

http://en.wikipedia.org/wiki/Iostream
jaymon333




PostPosted: Fri Oct 12, 2007 10:38 pm   Post subject: RE:Compiolation difficulties of code, cannot understand where I am going wrong...

What do you mean by shift it? you mean put the ':\' before the 'cout' in my script? If that is the case, that confuses me more, because the way I wrote it was IDENTICAL to the way it was written in a working script, I just tried to re-write it the same way in my compiler and it wouldn't work, but I could copy n paste the script from the site I was using and it did work.

By the way, does this seem like a good site for a beginner to start learning C++?:

http://www.cprogramming.com/tutorial/lesson1.html

That is also where I got the source code from too.

Thankyou very much for the reply!
rdrake




PostPosted: Fri Oct 12, 2007 10:44 pm   Post subject: Re: Compiolation difficulties of code, cannot understand where I am going wrong...

I may be no expert, but I reckon it should be something like this:
c++:
#include <iostream>

using namespace std;

int main() {
    cout << "Hey you! I am still alive! The World's End!!" << endl;
    cin.get();
}
Euphoracle




PostPosted: Fri Oct 12, 2007 10:51 pm   Post subject: Re: RE:Compiolation difficulties of code, cannot understand where I am going wrong...

jaymon333 @ Fri Oct 12, 2007 10:38 pm wrote:
What do you mean by shift it? you mean put the ':\' before the 'cout' in my script? If that is the case, that confuses me more, because the way I wrote it was IDENTICAL to the way it was written in a working script, I just tried to re-write it the same way in my compiler and it wouldn't work, but I could copy n paste the script from the site I was using and it did work.

By the way, does this seem like a good site for a beginner to start learning C++?:

http://www.cprogramming.com/tutorial/lesson1.html

That is also where I got the source code from too.

Thankyou very much for the reply!


You need to use the bit shift operator, which is <<
jaymon333




PostPosted: Fri Oct 12, 2007 10:53 pm   Post subject: RE:Compiolation difficulties of code, cannot understand where I am going wrong...

Wow thank you that worked, I can visually seee what you changed, but don't really understand why the changes made the differnce, but I guess in time I will learn that. When the file is read, put into exe and I use it, the comment comes up in DOS, how does that help me? What I am try to say is, how would you create a program out of that? I don't get how you can make it interactive, like a user clicking and typing words into a dictionary, and if it's in DOS, is it ever possible to get it onto CD format and open it like an application on another computer?
jaymon333




PostPosted: Fri Oct 12, 2007 10:56 pm   Post subject: RE:Compiolation difficulties of code, cannot understand where I am going wrong...

wow okay, this is all so confusing, but I kinda got a little better, I don't see why they never explained anything about the bit shift operator in the guide I was using from the link.... and it's hard when you don't have sombody in person who can teach it too you... Much harder learning it over the internet.
Euphoracle




PostPosted: Fri Oct 12, 2007 10:59 pm   Post subject: Re: RE:Compiolation difficulties of code, cannot understand where I am going wrong...

jaymon333 @ Fri Oct 12, 2007 10:53 pm wrote:
Wow thank you that worked, I can visually seee what you changed, but don't really understand why the changes made the differnce, but I guess in time I will learn that. When the file is read, put into exe and I use it, the comment comes up in DOS, how does that help me? What I am try to say is, how would you create a program out of that? I don't get how you can make it interactive, like a user clicking and typing words into a dictionary, and if it's in DOS, is it ever possible to get it onto CD format and open it like an application on another computer?


cout is simply the CommonOUTput. Cout is the first thing that most C++ programmers learn, and judging by what you're asking, I'd recommend you look up some books, ebooks possibly, for general programming theory. Theory before practice means you'll be much more informed before you throw yourself at a debugger. Now if only the board of education would listen to that *sigh*

In short, find a general programming theory book, read it, learn it, test yourself, and then move on to applying the syntax. Just because C++ the programming language, doesn't mean that's where you start. Same way you don't start playing music from a trumpet directly. You have to learn the theory.
Sponsor
Sponsor
Sponsor
sponsor
jaymon333




PostPosted: Fri Oct 12, 2007 11:15 pm   Post subject: RE:Compiolation difficulties of code, cannot understand where I am going wrong...

okay, I understand, so you want me to learn the theory before starting, but you caught me off gaurd with the syntax? What is that, and how does it work in relation to C++? Can you recommend any good C++ programming books to start off with for a beginner like me?
CodeMonkey2000




PostPosted: Sat Oct 13, 2007 12:07 am   Post subject: RE:Compiolation difficulties of code, cannot understand where I am going wrong...

Don't start with C++. Try Ruby.
Euphoracle




PostPosted: Sat Oct 13, 2007 12:23 am   Post subject: RE:Compiolation difficulties of code, cannot understand where I am going wrong...

The previous post sums it up nicely. Starting with something like this is often too difficult for an entry level programmer. As for books, I'd check out your local college library, or public library. They might have some of those "for dumbies" books. Those are really nice books because they explain things in common terms. After that, of course, you can move on to more advanced books and exercises. Remember, programmers limitted to syntax aren't programmers at all. The key to successful programming is being able to use your theory in conjunction with any syntax to achieve the same result, whether or not you'll be using one language more than the other. SYNTAX is not programming, it's an implementation of it.
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  [ 11 Posts ]
Jump to:   


Style:  
Search: