end1 error?

This is a discussion on end1 error? within the C++ Programming forums, part of the General Programming Boards category; Hello! Yes this is for homework, but I only have a few teeny questions. Why, when I compile my program, ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    21

    Invalid input?

    Hello! Yes this is for homework, but I only have a few teeny questions. Why, when I compile my program, does it give me three errors about end1 not being in iostream?? I know it is end(one) and not end(lowercase l).

    But it still should work, right?

    Also, how can I add a check to make sure the input is an integer and not, say, a letter?
    Thanks for your help.

    Code:
    //Palidrome 2.29
    
    #include <iostream>
    
    int main()
    {
    	using std::cout;
    	using std::cin;
    	using std::end1;
    
    	int integer;  //user input
    	int digitOne, digitTwo, digitThree, digitFour, digitFive; //breaks up input
    
    	cout << "Enter a five-digit integer: ";  //prompts user
    	cin >> integer;  //place-holder for input
    
    	digitOne = integer / 10000;
    	digitTwo = integer % 10000 / 1000;
    	digitFour = integer % 10000 % 1000 % 100 / 10;
    	digitFive = integer % 10000 % 1000 % 10;
    
    	if (digitOne == digitFive && digitTwo == digitFour)
    		cout << integer << " is a palindrome." << end1;
    	else
    		cout << integer << " is not a palindrome." << end1;
    	
    	return 0;
    }
    Last edited by deedlit; 09-09-2004 at 07:40 PM.

  2. #2
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    it is endl not a 1 but a l.

    yes I thought it was a 1 too but I found out it was endl.

    If that is unclear still (it would be to me) it is a lower case L.



    I am sure it is lower case L. I used it before...

    Edit: Yes it is lower case L. I just tried it and it worked for me.
    Last edited by Rune Hunter; 09-09-2004 at 07:35 PM.

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    21
    Thanks for your reply. The guy who was tutoring me told me that I was wrong when I had endl; in my pseudocode. I guess I should not listen to him next time and find a new tutor.

    Do you know of any way I can check for invalid input?
    Last edited by deedlit; 09-09-2004 at 07:39 PM.

  4. #4
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    LOL Your welcome. Or listen but maybe not do or check first. LOL


    Edit: YES! I helped someone!
    Last edited by Rune Hunter; 09-09-2004 at 07:39 PM.

  5. #5
    Registered User
    Join Date
    Oct 2003
    Posts
    21
    Do you know how to check for invalid input? I tried to make another while loop but it wouldn't run properly

  6. #6
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Code:
    cin >> integer;
    if( integer != (/* logical conditions for valid input */) return 0;
    digitOne = integer / 10000;

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, 09:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 10:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 02: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21