function call missing argument list

Simple program to validate input

Page 1 of 1

2 Replies - 6756 Views - Last Post: 13 April 2009 - 03:28 PM Rate Topic: -----

#1 zbumpers  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 26-January 09

function call missing argument list

Post icon  Posted 13 April 2009 - 01:09 PM

I'm trying to create a simple program that will validate my input with different outputs. Any help is appreciated, thanks.

//selection Menu 

#include <iomanip>
#include <iostream>

using namespace std;

int main()
{

int selection;

		cout <<"******************************************************************"<<endl;
		cout <<"******************************************************************"<<endl;
		cout <<"******************************************************************"<<endl;
		cout <<"1) Would you like to enter a book into the library?"<<endl;
		cout <<"2) Would you like to enter a borrowed book?"<<endl;
		cout <<"3) Would you like to sort all books in the library?"<<endl;
		cout <<"4) Would you like to list all the borrowed books?"<<endl;
		cout <<"******************************************************************"<<endl;
		cout <<"******************************************************************"<<endl;
		cout <<"******************************************************************"<<endl;
		endl;
		endl;
		
		do
	{
		//Find out how which option user picks and validates selection


		while (1) 
		{	cout <<"Press the number of your selection or q to quit."<<endl;
			cin>> selection;
		
			if (selection == 'q' || selection =='Q') 
			cout <<"stop"<<endl;
				break;
			
			if (selection = 1)
			{				
				cout <<"Enter book\n";
				break;
			}
			if (selection = 2)
				{
			
				cout <<"Enter borrowed book\n";
				break;
				}
			if (selection = 3)
					{
				
				cout <<"Sort list\n";
				break;
					}
			if (selection = 4)
						{
				
				cout <<"List borrowed books\n";
				break;
						}
			else

							{
				cout<<"\n\n\n\""<<selection<<"\" is not a valid selection"<<endl;
				cout<<"Please ";
				continue;
							}
		}
	}

}
			



Is This A Good Question/Topic? 0
  • +

Replies To: function call missing argument list

#2 trixt.er  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 46
  • View blog
  • Posts: 419
  • Joined: 28-September 08

Re: function call missing argument list

Posted 13 April 2009 - 02:14 PM

For starters your if statements are not doing what you would like them to do. They are not comparing number values rather they are assigning them to your variable.

Use the == for comparison in your if statements.

:^: Other than that it looks good!
Was This Post Helpful? 0
  • +
  • -

#3 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1376
  • View blog
  • Posts: 10,951
  • Joined: 06-February 08

Re: function call missing argument list

Posted 13 April 2009 - 03:28 PM

Several errors here.
  • == instead of =
  • cout << endl instead of just endl
  • while goes at the end of a do
  • you missed {} around your quit condition, it would break every time
Hope this helps :)

edit
Might help more if I remembered to post the fixed code! :)
//selection Menu

#include <iomanip>
#include <iostream>

using namespace std;

int main()
{

int selection;

        cout <<"******************************************************************"<<endl;
        cout <<"******************************************************************"<<endl;
        cout <<"******************************************************************"<<endl;
        cout <<"1) Would you like to enter a book into the library?"<<endl;
        cout <<"2) Would you like to enter a borrowed book?"<<endl;
        cout <<"3) Would you like to sort all books in the library?"<<endl;
        cout <<"4) Would you like to list all the borrowed books?"<<endl;
        cout <<"******************************************************************"<<endl;
        cout <<"******************************************************************"<<endl;
        cout <<"******************************************************************"<<endl;
        cout <<endl; // missing cout << here
        cout <<endl; // and here

        do
    {
        //Find out how which option user picks and validates selection


            cout <<"Press the number of your selection or q to quit."<<endl;
            cin>> selection;

            if (selection == 'q' || selection =='Q') {
            cout <<"stop"<<endl;
                return 0; // quit the program
            } // missing curly braces, it breaks every time

            if (selection == 1)
            {
                cout <<"Enter book\n";
                break;
            }
            if (selection == 2) // DOUBLE EQUALS!
                {

                cout <<"Enter borrowed book\n";
                break;
                }
            if (selection == 3)
                    {

                cout <<"Sort list\n";
                break;
                    }
            if (selection == 4)
                        {

                cout <<"List borrowed books\n";
                break;
                        }
            else

                            {
                cout<<"\n\n\n\""<<selection<<"\" is not a valid selection"<<endl;
                cout<<"Please ";
                continue;
                            }
        }while(1); // while goes at the end of a do/while loop
    }

Just a tip, you might wanna work on your indentation a little. It's quite hard to read as it is. :)

another edit,
Because I'm such a nice guy, I've indented it nicely (according to my standards)
People tend to indent differently, but this is *generally* nice looking code:
//selection Menu

#include <iomanip>
#include <iostream>

using namespace std;

int main() {
    int selection;

    cout <<"******************************************************************"<<endl;
    cout <<"******************************************************************"<<endl;
    cout <<"******************************************************************"<<endl;
    cout <<"1) Would you like to enter a book into the library?"<<endl;
    cout <<"2) Would you like to enter a borrowed book?"<<endl;
    cout <<"3) Would you like to sort all books in the library?"<<endl;
    cout <<"4) Would you like to list all the borrowed books?"<<endl;
    cout <<"******************************************************************"<<endl;
    cout <<"******************************************************************"<<endl;
    cout <<"******************************************************************"<<endl;
    cout <<endl; // missing cout << here
    cout <<endl; // and here

    do {
        //Find out how which option user picks and validates selection
        cout <<"Press the number of your selection or q to quit."<<endl;   
        cin>> selection;
        if (selection == 'q' || selection =='Q') {
            cout <<"stop"<<endl;
            return 0; // quit the program
        } // missing curly braces, it breaks every time

        if (selection == 1) {
            cout <<"Enter book\n";
            break;
        } if (selection == 2) { // DOUBLE EQUALS!
            cout <<"Enter borrowed book\n";
            break;
        } if (selection == 3) {
            cout <<"Sort list\n";
            break;
        } if (selection == 4) {
            cout <<"List borrowed books\n";
            break;
        } else {
            cout<<"\n\n\n\""<<selection<<"\" is not a valid selection"<<endl;
            cout<<"Please ";
            continue;
        }
    }while(1); // while goes at the end of a do/while loop
    return 0;
}

This post has been edited by gabehabe: 13 April 2009 - 03:32 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1