943,579 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 822
  • C++ RSS
Feb 12th, 2008
0

Haha, Newbie question here!

Expand Post »
Ok, no matter what compiler i use, i can never find a compiler that will build/compile/run a single file like the one I have used in my school.

i got Code::Blocks to compile my test file

the code is short:
// Test file
c++ Syntax (Toggle Plain Text)
  1. include <iostream>
  2. int main()
  3. {
  4. cout << "yarg!" end1;
  5. return 0;
  6. }

can anyone please help me? the book I have starts off with single file programs and this is a major mountain that I keep stopping at whenever I start to read this book.

Thank You
Last edited by Ancient Dragon; Feb 12th, 2008 at 11:12 pm. Reason: add code tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Sgt. Pepper is offline Offline
24 posts
since Feb 2008
Feb 12th, 2008
0

Re: Haha, Newbie question here!

it should read: cout << "yarg!" << endl; instead.
Reputation Points: 343
Solved Threads: 24
Veteran Poster
Sturm is offline Offline
1,067 posts
since Jan 2007
Feb 12th, 2008
2

Re: Haha, Newbie question here!

And you're likely experiencing problems with the std:: namespace. Try prefixing cout and endl with std:: .

Or, if you don't like doing that, just add
C++ Syntax (Toggle Plain Text)
  1. using namespace std;
after you include <iostream>.
Team Colleague
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
John A is offline Offline
5,055 posts
since Apr 2006
Feb 12th, 2008
0

Re: Haha, Newbie question here!

// Test file
c++ Syntax (Toggle Plain Text)
  1. include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. cout << "yarg!" << end1;
  6. return 0;
  7. }
No errors, yet the run, build, and other buttons of that sort are grayed and unusable.
Last edited by Ancient Dragon; Feb 12th, 2008 at 11:13 pm. Reason: add code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Sgt. Pepper is offline Offline
24 posts
since Feb 2008
Feb 12th, 2008
0

Re: Haha, Newbie question here!

You probably failed to create a new project. Select menu item File --> New Project, then select the Console Project icon then fill in the rest of the information. After that those buttons and menu items will be enabled.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Feb 12th, 2008
1

Re: Haha, Newbie question here!

It should be endl, not end1.

Also, you forgot to put a # symbol before 'include'. It should read:
c++ Syntax (Toggle Plain Text)
  1. #include <iostream>
Last edited by John A; Feb 12th, 2008 at 11:21 pm.
Team Colleague
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
John A is offline Offline
5,055 posts
since Apr 2006
Feb 12th, 2008
0

Re: Haha, Newbie question here!

Ok, now it works, i just started a new project, didnt even have to include the test file in it, but anyways thank you guys

also, how do you put the code in the special formated text thing on this forum?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Sgt. Pepper is offline Offline
24 posts
since Feb 2008
Feb 12th, 2008
1

Re: Haha, Newbie question here!

Use code tags. You can use [code] (code goes here) [/code] for any language, or for language-specific highlighting, you can do [code=language] (for example, [code=c++]) and of course [/code].
Last edited by John A; Feb 12th, 2008 at 11:36 pm.
Team Colleague
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
John A is offline Offline
5,055 posts
since Apr 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: build windows problem
Next Thread in C++ Forum Timeline: C++ forbids initialization of member





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC