|
-
September 8th, 2005, 11:48 PM
#1
What am i missing?
Code:
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) o statement must have while
Error:test.cpp(103,1):Compound statement missing }
-
September 8th, 2005, 11:57 PM
#2
Re: What am i missing?
Looks like u are missing a few braces.
 Originally Posted by bradleyc
Code:
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)  o statement must have while
Error:test.cpp(103,1):Compound statement missing }
C++ program ran... C++ program crashed... C++ programmer quit !!   
Regards
Shaq
-
September 9th, 2005, 01:37 AM
#3
Re: What am i missing?
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:
Code:
while(option != 1 && option != 2 && option != 3 && option != 4 && option != 5 && option != 6);
could be easily replaced with a simpler version:
Code:
while(option<1 && option>6);
I assume the definitions of the various functions being used are there. HTH. Regards.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
September 9th, 2005, 02:10 AM
#4
Re: What am i missing?
Than whats wrong with ... sorry, i just cant see it ...
Code:
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++];
}
}
}
-
September 9th, 2005, 02:17 AM
#5
Re: What am i missing?
There is a mismatch between the opening parenthesis "(" and the opening brace "{". It occurs twice in your code. Do you see?
-
September 9th, 2005, 02:19 AM
#6
Re: What am i missing?
 Originally Posted by bradleyc
Than whats wrong with ... sorry, i just cant see it ...
Code:
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
Code:
//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.
}
Last edited by humptydumpty; September 9th, 2005 at 02:24 AM.
-
September 9th, 2005, 02:44 AM
#7
Re: What am i missing?
 Originally Posted by humptydumpty
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:
Code:
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)
Last edited by exterminator; September 9th, 2005 at 04:32 AM.
Reason: is = will
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
September 9th, 2005, 02:54 AM
#8
Re: What am i missing?
 Originally Posted by exterminator
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:
Code:
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
Second thing in for loop either you write ++i or i++ both will work same.
anyway thanx.
Last edited by humptydumpty; September 9th, 2005 at 04:38 AM.
-
September 9th, 2005, 03:59 AM
#9
Sorry, still missing something...
Definately need my eyes checked...
Error:asstester.cpp(300,1) eclaration missing ;
Error:asstester.cpp(300,1):Compound statement missing }
Code:
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);
}
}
}
Last edited by bradleyc; September 9th, 2005 at 04:05 AM.
-
September 9th, 2005, 04:15 AM
#10
Re: What am i missing?
[ 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
-
September 9th, 2005, 04:18 AM
#11
Re: What am i missing?
 Originally Posted by humptydumpty
videoLib[i] = videoLib[i+1];
&
videoLib[i] = videoLib[i++];
//No difference both are same only
No Humpty - they are not the same!!! Try this small code out:
Code:
#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:Replacing a[i++] with a[i+1] doesnot modify i and hence the result would be Regards.
Last edited by exterminator; September 9th, 2005 at 04:23 AM.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
September 9th, 2005, 04:35 AM
#12
Re: What am i missing?
Yes u r right.
With for loop i was misplaced
anyway thanx
-
September 9th, 2005, 04:51 AM
#13
Re: Sorry, still missing something...
 Originally Posted by bradleyc
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.
Code:
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
-
September 10th, 2005, 07:14 PM
#14
Re: What am i missing?
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?
-
September 11th, 2005, 04:45 AM
#15
Re: What am i missing?
 Originally Posted by bradleyc
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/
You may also use google to search for other editors, if you don't like this one.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|