Thread: simple error...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    16

    simple error...

    hello,
    im doing a program but ive got a problem but i cant see where the error is coming from! it seems so simple, but then the simple ones always are....

    Code:
    	void telephone::findnme(void)
    			{
    				int i;
    				int result;
    				cout << "Finding...." << end1;
    				for (i=0; i,<MAX;i++) {
    				result = strcmp (np[i].name,name);
    				if result ==0)
    					cout <<"Book found" << end1;
    						else
    					cout <<	"book not found" << end1;
    				}
    			}
    got a sytax error on first line and then there was an error with the << part after the "finding...."

    thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Looks like end-one rather than end-ell
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    C++ n00bie :D
    Join Date
    Jul 2004
    Posts
    63
    Did you declare both cout and endl? By one of the three methods:

    using namespace std; (not recommended)
    using std::[command]; (without []'s, not best, but better)
    std::[command] (put std:: before each command, best way)

    You only gave that little piece so Im not sure, it could be something else.

    Note: Just a question, I do this sometimes, did you forget to include iostream?

    EDIT: ooo didnt notice that was a 1, im blind

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    lol - missed this as well

    > if result ==0)
    Missing (
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    May 2004
    Posts
    16
    so what would i include in std::[xyz] everything from the int part?
    I have put the iostream in, admittedly i did miss it from the start!

    cout is a statement in Cpp isnt it?

  6. #6
    the Wizard
    Join Date
    Aug 2004
    Posts
    109
    A little summon-up, to be sure:
    end1 should be endl..
    if result == 0) should be if (result == 0)
    -//Marc Poulsen -//MipZhaP

    He sat down, he programmed, he got an error...

  7. #7
    Registered User
    Join Date
    May 2004
    Posts
    16
    Still sadly getting them!

    except now i have a "forbids i with no type" error on line 7!

    but surely its been declared at the start?

  8. #8
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Show the revised code

  9. #9
    the Wizard
    Join Date
    Aug 2004
    Posts
    109
    Yes, the code and the errors Would be great..
    -//Marc Poulsen -//MipZhaP

    He sat down, he programmed, he got an error...

  10. #10
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Code:
    				for (i=0; i,<MAX;i++) {
    Remove comma.

  11. #11
    Registered User
    Join Date
    May 2004
    Posts
    16
    Sorry looked myself away and looked indepth to it!

    heres the re done code

    Code:
    //	  void book::findnme(void)
    	//	  {
    		//	  	  int i;
    		//	  	  int result;
    		//	  	  cout<< "Finding...." <<endl;
    			//	  for (i=0; i<MAX;i++) {
    		//	  result = strcmp (np[i].name);
    			//	  if (result ==0)
    				//	  cout<<"Book found" <<endl;
    				//	  	  else
    				//	  cout<<	ok not found" <<end1;
    			//	  }
    		//	  }
    Had to hash it out to let it build!

    ive got to the stage where it just says that the endl is undeclared, but i thought this was a function of Cpp or am i going mad?

    also just aquick one, how do u clear an array to start? my heads going backwards!

    thanks

  12. #12
    Registered User
    Join Date
    May 2004
    Posts
    16
    p.s. just seen my mistake, but it says at this point of file on this line

    Code:
    		result = strcmp (np[i].name);
    sorry about all this guys, ive been working too long and my inteligence is sliping away..

  13. #13
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    What the I am sillyI am sillyI am sillyI am silly is that crap you just posted?!?
    You realize that EVERY LINE IS COMMENTED OUT?

    How the hell are we suppose to help you when you don't give us anything that we can use?

  14. #14
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Assuming the the commenting was just a mistake you made when copying and pasting:
    you still have a end1 instead of endl
    strcmp takes 2 parameters

    try using std::cout and std::endl instead of cout and endl

  15. #15
    the Wizard
    Join Date
    Aug 2004
    Posts
    109
    Yes, remove those commentes next time, and they especially wont help you, if your trying to get a product out of that code
    The errors are as Thantos so beautifully wrote above
    -//Marc Poulsen -//MipZhaP

    He sat down, he programmed, he got an error...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM