Help Void Skip Blanks ()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 16800960
    New Member
    • May 2010
    • 22

    Help Void Skip Blanks ()

    I am stuck with this i need to declare the clrscr,pause and skip blanks functions like my code shows below
    Code:
    # include <iostream>
    
    using namespace std;
    void clrscr (); //Prototype
    void pause (); //prototype
    void skipBlanks (); // prototype
    int main ()
    
    {
    cout << "Calling function Clear Screen\n";
    clrscr();
    
    cout << "Calling function pause\n";;
    pause();
    }
    
      char ch;
      while(ch=cin.peek()==' ' || ch=='\t' 
            || ch=='\n' || ch=='\r') cin.get();} 
     
      string title, id; 
      double price; 
      {
      cout << "Enter your student ID: "; 
      cin >> id; 
      cout << "Enter a book title: ";
      cin >> title;
    
    system ("pause");}

    here are the errors i am getting in dev C++

    16 expected constructor, destructor, or type conversion before '(' token
    16 expected `,' or `;' before '(' token
    18 expected unqualified-id before "while"
    18 expected `,' or `;' before "while"
    19 expected declaration before '}' token


    Thanks

    Banfa by following your advice and changing the placement of the closing brace to after price the following occurs

    23 expected declaration before '}' token


    the code following was written by lecturer unedited i may have misplaced it in the program though
    Last edited by 16800960; May 21 '10, 08:52 AM. Reason: additional info
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Line 16 is a brace } and it ends the function main.

    The rest of the code following line 16 is not in a function which is not allowed in C++

    Comment

    • 16800960
      New Member
      • May 2010
      • 22

      #3
      Have fixed the pause and CLS code now need the code to

      Code:
      void displayMenu (){
         cout << "MAIN MENU\n";  stringchoices []=
      {cout << " 0. Exit "; cout <<  " 1. Enter Book "; cout << " 2. Find Book\n ";
      cout << "3. List All";    "4. Delete Book";   "5. Update Book\n";}
      I want to make the cout statement be called when voidDisplay menu () ,DisplayMenu () is used

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Instead of

        cout << "MAIN MENU\n";

        do this

        cout << "MAIN MENU" << endl;

        endl (end line) is more portable.

        Just get rid of stringchoices and use cout to display your menu.

        Comment

        • 16800960
          New Member
          • May 2010
          • 22

          #5
          Thanks BanFa i realise i should use endl though /n flushes th eline decreasing the chance of overloading the function right.

          so basically your saying declare above main

          Void DisplayMenu ()

          Then in Main Displaymenu (){ cout Statements }

          End.

          I know that it will cout if i declare as void dipslay menu (); { Cout

          what i want is function displayMenu () to display i keep getting linker errors if i use displaymenu () though

          so display menu is the cout statements using the void as prototype
          Last edited by Niheel; May 27 '10, 09:13 AM. Reason: unnecessary lines

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            endl also flushes the output so no need to worry about that.

            Look you basic structure for calling you dsiplayMenu function should be like this

            Code:
            void displayMenu();  // Predeclare Function 
            
            int main()
            {
                displayMenu();   // Call function
            }
            
            // Define function
            void displayMenu()
            {
                // cout statements here
            }

            Comment

            Working...