Thread: what is this error

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    4

    what is this error

    Hi sorry for another post but i'm an error and I have no clue how to fix it I followed what was written in the book and this is what I put in.
    "
    // Listing 2.2 using std::cout
    #include <iostream.h>
    int main()
    {
    std::cout << "Hello there.\n";
    std::cout << "Here is 5: " << 5 << "\n" ;
    std::cout << "The manipulator std::end1";
    std::cout << "writes a new line to the screen.";
    std::cout << std::end1
    std::cout << "Here is a very big number:\t" << 70000;
    std::cout << std::end1
    std::cout << "Here is the sum of 8 and 5:\t";
    std::cout << 8+5 << std::end1
    std::cout << "here's a fraction:\t\t";
    std::cout << (float) 5/8 << std::end1
    std::cout << "Don't forget to replace Jesse Libriry";
    std::cout << "with your name...\n";
    std::cout << "Jesse Librity is a C++ programmer!\n";
    std::sin.get()
    return 0;
    }
    "
    thes are the errors i'm getting line 10"..end1 undeclared (first use here) line 10"parse error before" line 12"confused by earlier errors, bailing out"
    Last edited by a.lost.soul; 12-30-2002 at 03:27 AM.

  2. #2
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176
    i added comments...

    Code:
    // Listing 2.2 using std::cout
    #include <iostream.h>   //**should be <iostream> not <iostream.h>
    int main()
    {
    std::cout << "Hello there.\n";
    std::cout << "Here is 5: " << 5 << "\n" ;
    std::cout << "The manipulator std::end1";
    std::cout << "writes a new line to the screen.";
    std::cout << std::end1   //**need a semicolin
    std::cout << "Here is a very big number:\t" << 70000;
    std::cout << std::end1   //**need a semicolin
    std::cout << "Here is the sum of 8 and 5:\t";
    std::cout << 8+5 << std::end1   //**need a semiclin
    std::cout << "here's a fraction:\t\t";
    std::cout << (float) 5/8 << std::end1   //**semicolin
    std::cout << "Don't forget to replace Jesse Libriry";
    std::cout << "with your name...\n";
    std::cout << "Jesse Librity is a C++ programmer!\n";
    std::sin.get()   //**semicolin
    return 0;
    }
    mostly missing semicolins...
    If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    4
    yea I fixed most of the probles it just where it says
    std::cout << "here's a fraction:\t\t";
    I get the error " unterminated character constant
    and also in
    std::cout << "here's a fraction:\t\t";
    same error

  4. #4
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176
    ah.. i think you were putting end1 (end one) it should be endl (endL but with a lowercase l).

    also, it should be std::cin.get() not std::sin.get() at the end.
    If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?

  5. #5
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Originally posted by a.lost.soul
    yea I fixed most of the probles it just where it says
    std::cout << "here's a fraction:\t\t";
    I get the error " unterminated character constant
    and also in
    std::cout << "here's a fraction:\t\t";
    same error
    There is no error in that line, the error is because of the line under it, the end1 which should be endl;
    none...

  6. #6
    Registered User
    Join Date
    Dec 2002
    Posts
    4
    using the end1 was my first mistake but there all endl now. i've attached a screenshot and the error is highlighted if that helps

  7. #7
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    I can't see the screenshot, but anyways, this is a working code:
    [code]
    #include <iostream>
    int main()
    {
    std::cout << "Hello there.\n";
    std::cout << "Here is 5: " << 5 << "\n" ;
    std::cout << "The manipulator std::end1";
    std::cout << "writes a new line to the screen.";
    std::cout << std::endl;
    std::cout << "Here is a very big number:\t" << 70000;
    std::cout << std::endl;
    std::cout << "Here is the sum of 8 and 5:\t";
    std::cout << 8+5 << std::endl;
    std::cout << "here's a fraction:\t\t";
    std::cout << (float) 5/8 << std::endl;
    std::cout << "Don't forget to replace Jesse Libriry";
    std::cout << "with your name...\n";
    std::cout << "Jesse Librity is a C++ programmer!\n";
    std::cin.get();
    return 0;
    }
    [\code]

    Compare it with your's...
    You had a mistake when you were using: iostream.h
    among with std::cout, ...
    I'm not use if this is acceptable in your compiler, but as far as I know you should use iostream only( without .h )...
    none...

  8. #8
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    try this:

    #include<iostream>

    using namespace std;

    so you don't have to do "std::thing" every time, just type in "thing".

    Your error is commented (except for the endl's)

    Code:
    #include<iostream>
    
    int main()
    {
      std::cout << "Hello there.\n";
      std::cout << "Here is 5: " << 5 << "\n" ;
      std::cout << "The manipulator std::endl";
      std::cout << "writes a new line to the screen.";
      std::cout << std::endl                                //semicolon
      std::cout << "Here is a very big number:\t" << 70000;
      std::cout << std::endl                                //semicolon
      std::cout << "Here is the sum of 8 and 5:\t";
      std::cout << 8+5 << std::endl                    //semicolon
      std::cout << "here's a fraction:\t\t";
      std::cout << (float) 5/8 << std::endl          //semicolon
      std::cout << "Don't forget to replace Jesse Libriry";
      std::cout << "with your name...\n";
      std::cout << "Jesse Librity is a C++ programmer!\n";
      std::sin.get()                                               //cin not sin and semicolon
      return 0;
    }
    Last edited by Yoshi; 12-30-2002 at 09:45 PM.
    Yoshi

  9. #9
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176
    >>std::cout << "The manipulator std::endl"; // quotation mark boy!!

    what's wrong with this? if you mean that 'std::endl' is in the quotes, then i believe this is correct... he's output some information about std::endl, not tryint to use it.
    If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?

  10. #10
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    okay, rather interesting.
    Yoshi

  11. #11
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    so... here it is fixed for you
    Code:
    #include<iostream>
    
    using namespace std; // now u dont need all of those std::'s
    
    int main()
    {
    	cout << "Hello there.\n";
    	cout << "Here is 5: " << 5 << "\n" ;
    	cout << "The manipulator endl"<< endl; // an endl is placed out of quotes
    	cout << "writes a new line to the screen.";
    	cout << endl;                                //semicolon placed here
    	cout << "Here is a very big number:\t" << 70000;
    	cout << endl;                                //semicolon
    	cout << "Here is the sum of 8 and 5:\t";
    	cout << 8+5 << endl;                    //semicolon
    	cout << "here's a fraction:\t\t";
    	cout << (float) 5/8 << endl;          //semicolon
    	cout << "Don't forget to replace Jesse Libriry";
    	cout << "with your name...\n";
    	cout << "Jesse Librity is a C++ programmer!\n";
    	cin.get();                                               //cin not sin and semicolon
    	return 0;
    }

  12. #12
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146

    Re: what is this error

    Originally posted by a.lost.soul
    i'm an error
    Ha, ha, ha. Oh, that's classic. That's when you have a hardware error between your keyboard and your chair. Heh, heh. Thanks for the laugh, lost.soul.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM