Expected primary expression before '<<' token...

This is a discussion on Expected primary expression before '<<' token... within the C++ Programming forums, part of the General Programming Boards category; I've taken about a three or four months break from programming without even having an extremely good grasp on it ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    13

    Expected primary expression before '<<' token...

    I've taken about a three or four months break from programming without even having an extremely good grasp on it in the first place, so I decided to write a really quick program to refresh my memory. The last thing I need is to be bogged down with unexplained errors.

    This is the only error throughout my entire code, and I get it EVERY SINGLE TIME I use either the operators << or >> after using either cout or cin. I am using Dev-C++ 5

    Code:
    #include <iostream>
    
    using namespace std;
    
    void addition(void);
    void subtraction(void);
    void menu(void);
    
    int main()
    {
    	menu();
    	return 0;
    }
    
    void menu(void)
    {
    	int menuselection;
    	int quitselection;
    
    	cout << "Please select from the list below:"; << endl;
    	cout << "1. Addition"; <<endl;
    	cout << "2. Subtraction"; <<endl;
    	cin >> menuselection;
    
    	switch (menuselection)
    	{
    		case 1:
    		addition();
    		break;
    
    		case 2:
    		subtraction();
    		break;
    
    		default:
    		menu();
    	}
    
    	cout << "Do you wish to continue or quit?" <<endl;
    	cout << "1. Continue" <<endl;
    	cout << "2. Quit" <<endl;
    	cin >> quitselection;
    
    	if (quitselection == 1)
    		menu();
    
    	else
    		return;
    }
    
    void addition(void)
    {
    	float number1;
    	float number2;
    
    	cout << "Enter a number upon which you wish to add."; <<endl;
    	cin >> number1;
    	cout << "Enter a number to add to the previous number."; <<endl;
    	cin >> number2;
    	cout << number1+number2; <<endl;
    }
    
    void subtraction(void)
    {
    	float number1;
    	float number2;
    
    	cout << "Enter a number from wish you wish to deduct." <<endl;
    	cin >> number1;
    	cout << "Enter a number to subtract from the previous number." <<endl;
    	cin >> number2;
    	cout << number1-number2; <<endl;
    }

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Code:
    	cout << "1. Addition"; <<endl;
    You have a bunch of these -- terminating the statement and then trying to continue it (but the second << has no left operand).
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    45
    or in simpler terms...

    This...

    Code:
    cout << "1. Addition"; <<endl;
    Becomes...

    Code:
    cout << "1. Addition" << endl;

  4. #4
    Registered User
    Join Date
    Oct 2004
    Posts
    13
    Yeah... I get that now... I don't know where I got it in my head that I needed more than one per cout or cin... <.<

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM

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