Click to See Complete Forum and Search --> : What am i missing?
bradleyc
September 8th, 2005, 11:48 PM
void displayMenu()
{
do
{
clrscr();
cout << " " << endl;
cout << " --------------------------- " << endl;
cout << " Welcome to the Video System " << endl;
cout << " --------------------------- " << endl;
cout << " " << endl;
cout << " 1. Add New Video " << endl;
cout << " 2. Borrow Video " << endl;
cout << " 3. Modify Video Record " << endl;
cout << " 4. Delete Video " << endl;
cout << " 5. Report of Available videos " << endl;
cout << " 6. Exit ";
cout << " " << endl;
cout << " Please select an option 1-6: ";
cin >> option;
switch(option)
{
case 1:
doAdd();
break;
case 2:
doBorrow();
break;
case 3:
doModify();
break;
case 4:
doDelete();
break;
case 5:
doReport();
break;
case 6:
doExit();
break;
default:
cout << "Error: Invalid Option";
break;
}
while(option != 1 && option != 2 && option != 3 && option != 4 && option != 5 && option != 6);
)
Error:test.cpp(102,2):Expression syntax
Error:test.cpp(103,1):Statement missing ;
Error:test.cpp(103,1):Compound statement missing }
Error:test.cpp(103,1):do statement must have while
Error:test.cpp(103,1):Compound statement missing }
Vedam Shashank
September 8th, 2005, 11:57 PM
Looks like u are missing a few braces.
void displayMenu()
{
do
{
clrscr();
cout << " " << endl;
cout << " --------------------------- " << endl;
cout << " Welcome to the Video System " << endl;
cout << " --------------------------- " << endl;
cout << " " << endl;
cout << " 1. Add New Video " << endl;
cout << " 2. Borrow Video " << endl;
cout << " 3. Modify Video Record " << endl;
cout << " 4. Delete Video " << endl;
cout << " 5. Report of Available videos " << endl;
cout << " 6. Exit ";
cout << " " << endl;
cout << " Please select an option 1-6: ";
cin >> option;
switch(option)
{
case 1:
doAdd();
break;
case 2:
doBorrow();
break;
case 3:
doModify();
break;
case 4:
doDelete();
break;
case 5:
doReport();
break;
case 6:
doExit();
break;
default:
cout << "Error: Invalid Option";
break;
}
}
while(option != 1 && option != 2 && option != 3 && option != 4 && option != 5 && option != 6);
}//NOT )
Error:test.cpp(102,2):Expression syntax
Error:test.cpp(103,1):Statement missing ;
Error:test.cpp(103,1):Compound statement missing }
Error:test.cpp(103,1):do statement must have while
Error:test.cpp(103,1):Compound statement missing }
exterminator
September 9th, 2005, 01:37 AM
Some inputs from my side:
1. clrscr() is not a part of standard C++.
2. The variable 'option' is not defined anywhere in the function.
3. The missing and mismatched braces as pointed by Vedam Shashank
4. This code:while(option != 1 && option != 2 && option != 3 && option != 4 && option != 5 && option != 6);could be easily replaced with a simpler version:while(option<1 && option>6);I assume the definitions of the various functions being used are there. HTH. Regards.
bradleyc
September 9th, 2005, 02:10 AM
Than whats wrong with ... sorry, i just cant see it ...
void doDelete()
{
clrscr();
char inputv, input;
cout << " " << endl;
cout << " --- DELETE VIDEO MENU ---- " << endl;
cout << " Would you like to delete a video (y/n)?: ";
cin >> inputv;
if (inputv == 'y' || inputv == 'Y')
(
int item, location;
clrscr();
cout << " " << endl;
cout << " What is the video's name ? ";
cin >> item;
location = searchName(videoLib, numElements, item);
if (location == -1)
(
clrscr();
cout << " " << endl;
cout << " Invaild Input" <<endl;
cout << " Press any key to exit ....";
input = getch();
}
else
{
{
for(int i = location; i < numElements - 1; i++)
}
videoLib[i] = videoLib[i++];
}
}
}
olivthill
September 9th, 2005, 02:17 AM
There is a mismatch between the opening parenthesis "(" and the opening brace "{". It occurs twice in your code. Do you see?
humptydumpty
September 9th, 2005, 02:19 AM
Than whats wrong with ... sorry, i just cant see it ...
void doDelete()
{
clrscr();
char inputv, input;
cout << " " << endl;
cout << " --- DELETE VIDEO MENU ---- " << endl;
cout << " Would you like to delete a video (y/n)?: ";
cin >> inputv;
if (inputv == 'y' || inputv == 'Y')
(
int item, location;
clrscr();
cout << " " << endl;
cout << " What is the video's name ? ";
cin >> item;
location = searchName(videoLib, numElements, item);
if (location == -1)
(
clrscr();
cout << " " << endl;
cout << " Invaild Input" <<endl;
cout << " Press any key to exit ....";
input = getch();
}
else
{
{// what's the nee for this braces
for(int i = location; i < numElements - 1; i++)
}
videoLib[i] = videoLib[i++];
}
}
}
Just check out Your code Once again clearfully
syntax and logic That's all you have to do,don't know for what u r trying any way what is this
just check for following step
1) check for your all opening and closed {} & () braces
2) check for your for loop
3) for loop execute only next statement after the loop .if multipel statement is there put all in Braces. your for loop i don't know what r doing
4) Multiple time increment of i
//what's the need of this.
else
{
{// what's the nee for this braces
for(int i = location; i < numElements - 1; i++)
}
videoLib[i] = videoLib[i++];
}
//it should be like
else
{
for(int i = location; i < numElements - 1; i++)
videoLib[i] = videoLib[i++];//no need to increment i when u r already doing in loop & what's the meaning of this statement.
}
exterminator
September 9th, 2005, 02:44 AM
4) Multiple time increment of i
videoLib[i] = videoLib[i++];
videoLib[i] = videoLib[i++];//no need to increment i when u r Ok..What he wants to do seems logical. He needs to assign the nth videoLib member to (n-1)th one. But the construct is wrong. He might have had thought of achieving this:for(.....;...;++i)
{
//....
videoLib[i] = videoLib[i+1];
//....
}Humptydumpty - you traced it but you, i think, forgot to make the change ;) . Regards.
EDIT: The logic for deleting the video is wrong. You are just over-writing the data by shifting one location back and hence you are left with two copies (or more on subsequent calls to delete) of the same data at the end of the array or whatever you are using. This will ultimately screw up whole of the container (array) that you are using and what you will end up with would be a complete mess (upon subsequent additions, removals). Why don't you use std::list for maintaining a collection of videos in the library. It is best suited for you. (You could also use std::vector but removing this way in that also needs shifting all the rest of the members occuring later, one place ahead, although taken care of automatically - you dont need to worry about the shifting - just call erase() member function)
humptydumpty
September 9th, 2005, 02:54 AM
Ok..What he wants to do seems logical. He needs to assign the nth videoLib member to (n-1)th one. But the construct is wrong. He might have had thought of achieving this:for(.....;...;++i)
{
//....
videoLib[i] = videoLib[i+1];
//....
}Humptydumpty - you traced it but you, i think, forgot to make the change ;) . Regards.
no exterminator i didn't forget anything just pointed out what he is doing that's all. i told him all the possibility and ask him to do all of his work and then move ahead.
and one thing more
Moved
Second thing in for loop either you write ++i or i++ both will work same.
anyway thanx.
bradleyc
September 9th, 2005, 03:59 AM
Definately need my eyes checked...
Error:asstester.cpp(300,1):Declaration missing ;
Error:asstester.cpp(300,1):Compound statement missing }
void doModify()
{
clrscr();
char inputv, input1, input2;
cout << " " << endl;
cout << " --- MODIFY VIDEO MENU ---- " << endl;
cout << " Would you like to modify a video (y/n)?: ";
cin >> inputv;
if (inputv == 'y' || inputv == 'Y')
{
clrscr();
int item1, location1, location2;
char item2[20];
cout << " " << endl;
cout << " -- Current Record -- " << endl;
cout << " What is the Video Number?: ";
cin >> item1;
location1 = searchNum(videoLib, numElements, item1);
if (location1 == -1)
{
clrscr();
cout << " " << endl;
cout << " Invaild Input" <<endl;
cout << " Press any key to exit ....";
input1 = getch();
}
else
{
cout << " What is the Video Name?: ";
cin >> item2;
location2 = searchName(videoLib, numElements, item2);
if (location2 == -1)
{
clrscr();
cout << " " << endl;
cout << " Invaild Input" <<endl;
cout << " Press any key to exit ....";
input2 = getch();
}
else
{
cout << " " << endl;
cout << " -- New Record -- " << endl;
cout << " What is the Video Number?: ";
cin >> videoLib[location1].videoNum;
cout << " What is the Video Name?: ";
cin.getline(videoLib[location2].videoName, 30);
}
}
}
Siddhartha
September 9th, 2005, 04:15 AM
[ merged ]
bradleyc - Please donot create a new thread to continue an existing discussion. When you reply to an existing thread - those that helped you receive notifications that you need help again.
This is in your interest.
Thank you for your understanding.
Best Regards,
Siddhartha
exterminator
September 9th, 2005, 04:18 AM
videoLib[i] = videoLib[i+1];
&
videoLib[i] = videoLib[i++];
//No difference both are same onlyNo Humpty - they are not the same!!! Try this small code out:#include <iostream>
int main(){
int a[6] = {0,1,2,3,4,5};
for (int i=0;i<5;++i){
std::cout << a[i++] << "\t";
}
return 0;
}Output:0 2 4 Replacing a[i++] with a[i+1] doesnot modify i and hence the result would be 1 2 3 4 5Regards.
humptydumpty
September 9th, 2005, 04:35 AM
Yes u r right.
With for loop i was misplaced
anyway thanx
Paul McKenzie
September 9th, 2005, 04:51 AM
Definately need my eyes checked...
1) Get an editor that does brace matching. The Visual C++ editor, plus many third-party editors for Windows and Linux/UNIX exist that have this capability.
2) Organize your code so that it is easily detected that there are missing braces.
void doModify()
{
clrscr();
char inputv, input1, input2;
cout << " " << endl;
cout << " --- MODIFY VIDEO MENU ---- " << endl;
cout << " Would you like to modify a video (y/n)?: ";
cin >> inputv;
if (inputv == 'y' || inputv == 'Y')
{
clrscr();
int item1, location1, location2;
char item2[20];
cout << " " << endl;
cout << " -- Current Record -- " << endl;
cout << " What is the Video Number?: ";
cin >> item1;
location1 = searchNum(videoLib, numElements, item1);
if (location1 == -1)
{
clrscr();
cout << " " << endl;
cout << " Invaild Input" <<endl;
cout << " Press any key to exit ....";
input1 = getch();
}
else
{
cout << " What is the Video Name?: ";
cin >> item2;
location2 = searchName(videoLib, numElements, item2);
if (location2 == -1)
{
clrscr();
cout << " " << endl;
cout << " Invaild Input" <<endl;
cout << " Press any key to exit ....";
input2 = getch();
}
else
{
cout << " " << endl;
cout << " -- New Record -- " << endl;
cout << " What is the Video Number?: ";
cin >> videoLib[location1].videoNum;
cout << " What is the Video Name?: ";
cin.getline(videoLib[location2].videoName, 30);
}
}
}
} // <-- This is missing
You are missing the last ending brace.
Regards,
Paul McKenzie
bradleyc
September 10th, 2005, 07:14 PM
1) Get an editor that does brace matching. The Visual C++ editor, plus many third-party editors for Windows and Linux/UNIX exist that have this capability.
What other editors for Windows have this capability?
SuperKoko
September 11th, 2005, 04:45 AM
What other editors for Windows have this capability?
I know a good freeware text editor, which is very fast and small, and has parenthesis checking.
http://www.crimsoneditor.com/ (crimson editor)
You may also use google to search for other editors, if you don't like this one.
Paul McKenzie
September 11th, 2005, 08:08 AM
What other editors for Windows have this capability?Practically every commercial editor designed for programmers has this capability.
Brief, MultiEdit and SlickEdit are examples. For free editors, I believe that the Emacs editor has this capability.
Regards,
Paul McKenzie
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.