Void assistance

I have written the following code to display 3 void elements

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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");}


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

I need help to sort it out here is a list of the errors i am having and im fairly sure i haven't declared the functions correctly

so i would be greatful if a kind person could correct my code for me or provide some major assistance

as far as i can tell the char ch area is to be used to test for blanks/newline characters and ignore them but by setting void it would ignore this ?
Last edited on
you code, after pause();, is not in a function at all. Also, I'm not sure if you are able to put a ';' in a statement, like you did in the while statement. And at last, keep in mind that there is still a '}' after the system function.
Last edited on
I copied the code my lecturer wrote otherwise what is after pause can you see any way to fix it.

as far as the brace after the complier stated to but a brace as a warning i don't think it is necessary though and the ; in the while again was listed.
Thanks
Last edited on
Obviously, this is not code anyone who knows C++ would write.

You have function declarations in your code, but where are the definitions? None of your functions will do anything without definitions.

Why do you have a closing bracket after your while loop?
Why do you have a set of brackets after you declare a double?
Last edited on
also, I don't think anyone else has pointed this out yet but your program ends after line 15.
That program is very garbled. It looks like you have had some kind of cut'n'paste accident...
I know the program ends after line 15 the problem being that the code it has for this is

i garbled it myself as well i think i was getting flustered as far as the functions go

the code i had should of been

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# include <iostream>

using namespace std;
void clrscr( ); //Prototype
int main ()

{
    cout << "Calling function Clear Screen\n";
clrscr( ) ;
}

void clrscr( ) //Implementation
{

system( "pause" );
}
    


for the clear screen etc

same for the pause function though
as they were pieces but i will admit i didn't declare the function correctly above but that can be changed by adding another function in it is the section with the skipblanks and char ch that is my primary concern as i can make it clearscreen but i need to add another void CLRSCR() and VOid pause () i believe as that is what i have in the original code which doesn't have compiler errors

though then again i am happy to be corrected. furthermore a rewrite would be fine as long as it uses the void pause,Void cls and void skip blanks though all the functions are meant to be called using the pause () etc type call just prototyped with the void statements. if someone can write me a fucntion to skip the blanks using the code provided i can rework the code fine.
Topic archived. No new replies allowed.