473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
Expand|Select|Wrap|Line Numbers
  1.  
  2. # include <iostream>
  3.  
  4. using namespace std;
  5. void clrscr (); //Prototype
  6. void pause (); //prototype
  7. void skipBlanks (); // prototype
  8. int main ()
  9.  
  10. {
  11. cout << "Calling function Clear Screen\n";
  12. clrscr();
  13.  
  14. cout << "Calling function pause\n";;
  15. pause();
  16. }
  17.  
  18.   char ch;
  19.   while(ch=cin.peek()==' ' || ch=='\t' 
  20.         || ch=='\n' || ch=='\r') cin.get();} 
  21.  
  22.   string title, id; 
  23.   double price; 
  24.   {
  25.   cout << "Enter your student ID: "; 
  26.   cin >> id; 
  27.   cout << "Enter a book title: ";
  28.   cin >> title;
  29.  
  30. system ("pause");}
  31.  
  32.  

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
May 21 '10 #1

✓ answered by Banfa

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

Expand|Select|Wrap|Line Numbers
  1. void displayMenu();  // Predeclare Function 
  2.  
  3. int main()
  4. {
  5.     displayMenu();   // Call function
  6. }
  7.  
  8. // Define function
  9. void displayMenu()
  10. {
  11.     // cout statements here
  12. }
  13.  

5 2449
Banfa
9,065 Expert Mod 8TB
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++
May 21 '10 #2
Have fixed the pause and CLS code now need the code to

Expand|Select|Wrap|Line Numbers
  1.  
  2. void displayMenu (){
  3.    cout << "MAIN MENU\n";  stringchoices []=
  4. {cout << " 0. Exit "; cout <<  " 1. Enter Book "; cout << " 2. Find Book\n ";
  5. cout << "3. List All";    "4. Delete Book";   "5. Update Book\n";}
  6.  
  7.  
I want to make the cout statement be called when voidDisplay menu () ,DisplayMenu () is used
May 26 '10 #3
Banfa
9,065 Expert Mod 8TB
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.
May 26 '10 #4
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
May 27 '10 #5
Banfa
9,065 Expert Mod 8TB
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

Expand|Select|Wrap|Line Numbers
  1. void displayMenu();  // Predeclare Function 
  2.  
  3. int main()
  4. {
  5.     displayMenu();   // Call function
  6. }
  7.  
  8. // Define function
  9. void displayMenu()
  10. {
  11.     // cout statements here
  12. }
  13.  
May 27 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Helmut Jarausch | last post by:
Hi, entering help('rstrip') or help('ljust') into IDLE's shell window I only get no Python documentation found ...
3
by: sachin bond | last post by:
this code does not work.... plz help...... void breaker() {
2
by: Ernst Berg | last post by:
Thankfully there is a C language group! Hello! I am a hobyist who is rediscovering writing C programs on Linux. I use GCC and I am at a loss as to why the compile fails to find the...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
0
by: Ben Harper | last post by:
I am stuck using VC7 right now, so I can't test this on 7.1, but I believe it is a bug in the compiler, although I hope it isn't. Please could someone confirm this for me, prove me wrong, or suggest...
9
by: silverchrono | last post by:
this is my first semester in C and im trying to figure out how to reset a counter. heres why im trying to do. void text() 59 printf("You can end entering the text by using '#'\n"); 60 int...
34
by: Registered User | last post by:
Hi experts, I'm trying to write a program that replaces two or more consecutive blanks in a string by a single blank. Here's what I did: #include <stdio.h> #include <string.h> #define MAX 80
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
6
by: priyajohal | last post by:
#include<fstream.h> #include<process.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<dos.h> #include<ctype.h> #include<stdio.h> void setup() void help();
4
by: moon24 | last post by:
Hi im working with linked list and i have to implement a function that deletes the duplicates of a number. for example if given 2 7 1 7 12 7 then the result should be 2 7 1 12 here is what I have:...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.