Thread: Void Help ()

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    8

    Smile Void Help ()

    Here is the code i have so far i need to define the elements using void

    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");}
    and write the function getblanks ();
    prototyped by void getBlanks ()

    i think that i have done the first part okay after trying to complie the code i hav eincluded i get the following errors

    18 expected unqualified-id before "while"
    18 expected `,' or `;' before "while"
    19 expected declaration before '}' token

    Any help or fixed code would be greatly appriciated

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738

    Angry

    O_o... I know you... You run away just before i delivered you the same project, didn't you!!!!!!!
    Devoted my life to programming...

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Indentation is seriously messed up. You need to fix it.
    Then you realize that pretty much all code is outside the main function. Outside any function. This isn't allowed. The code must be inside a function.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    8
    Sipher ??

    Elsysia yes i relaised this although i think the code supplied is wrong any way to write it using the void statements and the char ch which i was told is to be used as a check for whitespace/newline characters

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    Code:
    while(ch=cin.peek()==' '
    precedence problem?

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    8
    it maybe a precedence issue what would be nice is if you could create a function that skips blanks using the void skipBlanks as a prototype and calling it with the skipBlanks () which runs a check for newline or whitespace characters etc which maybe the code is used as a guide what to check for.

    Any help would be greatly appriciated by changing the programs structure

    i get errors on line 25 - 29

    28 expected constructor, destructor, or type conversion before '>>' token
    all stem from the cout statement


    Code:
    cout << "Calling function Clear Screen\n";
    clrscr();
    
    cout << "Calling function pause\n";;
    pause();
    void pause ();
    void clrscr ();
    
      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;
    }
    now this has line 10 to 29 i have skipped the prototypes and system ('pause') and kept it all in main () is there any way to even use the function provided i would be happy with a rewrite or similar even if it is on that singular function thanks.
    Last edited by 16800960; 05-24-2010 at 09:26 PM.

  7. #7
    Registered User
    Join Date
    May 2010
    Posts
    8
    Solved these on my own thanks for the help

  8. #8
    Registered User
    Join Date
    May 2010
    Posts
    8
    Quote Originally Posted by 16800960 View Post
    Solved these on my own thanks for the help
    Apologies if this seems sarcastic i just re read what i typed so to clarify it is a truthful statement
    Last edited by 16800960; 05-29-2010 at 10:11 PM. Reason: spelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Matrix operations using objects
    By circuitbreaker in forum C++ Programming
    Replies: 7
    Last Post: 05-04-2010, 08:53 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  4. msvc just ate one of my source files
    By Eber Kain in forum C++ Programming
    Replies: 6
    Last Post: 07-01-2004, 05:40 AM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM