C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 21st, 2003, 08:28 PM
Obscurity Obscurity is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Monrovia, Los Angeles County, California
Posts: 45 Obscurity User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 19 sec
Reputation Power: 6
endl;

Alright, Im reading that 'Teach yourself C++ in 21 days' online book, and i have a question that i'm sure one of you can answer. I have the code which looks like this:

Code:
1:     // Listing 2.2 using cout
2:
3:     #include <iostream.h>
4:     int main()
5:     {
6:        cout << "Hello there.\n";
7:        cout << "Here is 5: " << 5 << "\n";
8:        cout << "The manipulator endl writes a new line to the screen." <<  endl;
9:        cout << "Here is a very big number:\t" << 70000 << endl;
10:       cout << "Here is the sum of 8 and 5:\t" << 8+5 << endl;
11:       cout << "Here's a fraction:\t\t" << (float) 5/8 << endl;
12:       cout << "And a very very big number:\t" << (double) 7000 * 7000 << endl;
13:       cout << "Don't forget to replace Jesse Liberty with your name...\n";
14:       cout << "Obscurity is a C++ programmer!\n";
15:        return 0;
16: }


Now, We are looking at line 8, and when I try to compile it I get an error. So im wondering if there has to be something before you can use the endl; endings...Or something similar, any ideas?

Reply With Quote
  #2  
Old March 21st, 2003, 08:32 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 26
looks fine to me, what is the error u r recieving?

Reply With Quote
  #3  
Old March 21st, 2003, 10:03 PM
Obscurity Obscurity is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Monrovia, Los Angeles County, California
Posts: 45 Obscurity User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 19 sec
Reputation Power: 6
Odd, instead of making it just a source file and then compiling...I made it a project and it worked without flaws. Does this happen to make a difference?

Reply With Quote
  #4  
Old March 21st, 2003, 10:20 PM
7stud 7stud is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2001
Posts: 1,327 7stud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 44 m 50 sec
Reputation Power: 9
Hi,

First of all, I tried to learn C++ from that book, which I bought, and it's horrible. You're never going to learn C++ in 21 days, so forget it--especially with that book, but feel free to ask all the questions you are going to have with that book as a tutor. Just remember: don't ever trust anything it says. If you don't understand something, it is most likely the book that is wrong or confusing, not your thinking process.

It sounds like you're using VC++ for your compiler. For every program you create, you need to start off by creating a project. Then you creat a source file inside the project for your program. Click on New and the Projects tab should be selected. Then select Win32 Console Project, give your project a name, click on OK. Select empty project, click on Finish, and click on OK.

To create a source file in your project, click on New again. This time the Files tab will be selected. Click on C++ source file, give it a name, and click on OK. Then you're set to go.

There is one other thing called a "project workspace." The project workspace is the folder in which everything related to the project is stored. It has an extension .dsw. When you want to work on a project(i.e. your program), you need to open the project workspace using the File menu item, and your project will be displayed along with it's source file.

The hierarchy is: the project workspace contains your project which contains your source file. You can delete a file out of your project by highlighting it in File View, and hitting the delete key, but it will still exist in your project folder, so you won't be able to make a permanent mistake. After you delete a source file from your project, if you minimize VC++ and navigate to the folder containing your project, you''ll notice that your source file will still be there. If you delete it out of the folder, then it will be gone permanently--actually then it will still go to your recycle bin. Kind of complicated, eh?

Last edited by 7stud : March 21st, 2003 at 10:34 PM.

Reply With Quote
  #5  
Old March 21st, 2003, 11:56 PM
Obscurity Obscurity is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Monrovia, Los Angeles County, California
Posts: 45 Obscurity User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 19 sec
Reputation Power: 6
Im working with Dev-C++ compiler.

Reply With Quote
  #6  
Old March 22nd, 2003, 12:49 AM
7stud 7stud is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2001
Posts: 1,327 7stud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 44 m 50 sec
Reputation Power: 9
lol, never mind.

Reply With Quote
  #7  
Old March 22nd, 2003, 01:06 AM
Obscurity Obscurity is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Monrovia, Los Angeles County, California
Posts: 45 Obscurity User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 19 sec
Reputation Power: 6
Do you have a better online reference manuel? Im looking just for at least the basics, until I can get better and better at it.

Reply With Quote
  #8  
Old March 22nd, 2003, 01:02 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 3,799 dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Month 9 h 55 m 28 sec
Reputation Power: 437
Quote:
Originally posted by Obscurity
Do you have a better online reference manuel? Im looking just for at least the basics, until I can get better and better at it.


The Dev-C++ IDE should have a help file for using the IDE. Plus, the Dev-C++ resources include a GNU C Library Reference, though you will need to use the Package Manager to install it and I found that version 4 doesn't let you install packages.

I installed Dev-C++ nearly two months ago. However, I rarely use the IDE, but rather have been using their MinGW compilers from the command line. I'm also studying Linux systems programming and this approach is almost identical between the two.

Add the Dev-C++ bin directory to your search path. The C++ compiler is g++ (gcc is the C compiler). It not only compiles source code, but it also links object files and libraries and creates an executable. The command to create an executable, prog.exe, out of the source files src1.cpp and src2.cpp, linking in the libwsock32.a library and displaying all warnings and errors would be:
g++ -Wall -o prog src1.cpp src2.cpp -lwsock32

If you leave out the -o option, then the executable name defaults to a.exe (a.out under Linux).

Ideally, you would define your program with a makefile and run make on it, but the command line invocation should work for now. If you want to see what the makefile would look like, create a project with the Dev-C++ IDE and have it generate a makefile.

In order to list the options on the command line, type:
g++ --help | more
You will need to pipe to more because the output is longer than one screen. Of course, if your command prompt window is scrollable (eg, as under Win2k), then you won't need to pipe to more.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > endl;


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway