Computer Science Canada I cant find one error in my program |
Author: | HolyDude [ Sat Nov 08, 2008 10:09 pm ] | ||
Post subject: | I cant find one error in my program | ||
Hi, I am new to this board, this is a small program of mine and I compiled it in turbo c++, my dev wasnt working. I was resulted in 3 errors, 2 of which I correced by putting a curly bracked and ';' in the end. I am left with one more error which says Line Number 67 : Declaration syntax error
That is my program, It would be nice if anyone of you could find the error and correct it and paste it. Thank you. |
Author: | OneOffDriveByPoster [ Sat Nov 08, 2008 10:18 pm ] |
Post subject: | Re: I cant find one error in my program |
You are missing a } somewhere. |
Author: | HolyDude [ Sat Nov 08, 2008 10:26 pm ] |
Post subject: | RE:I cant find one error in my program |
Thats what am trying to find out ![]() |
Author: | OneOffDriveByPoster [ Sat Nov 08, 2008 11:05 pm ] |
Post subject: | Re: RE:I cant find one error in my program |
HolyDude @ Sat Nov 08, 2008 10:26 pm wrote: Thats what am trying to find out Seriously, it is simple enough that you can find it easily.![]() |
Author: | gitoxa [ Sat Nov 08, 2008 11:27 pm ] |
Post subject: | RE:I cant find one error in my program |
Quote: Line Number 67 : Declaration syntax error
This is a large clue. ![]() Actually, after going through it, there is another problem in the program that presents itself after you fix the current mistake you have. I'd post it but that'd be giving away your current problem. |
Author: | Saad [ Sat Nov 08, 2008 11:38 pm ] | ||
Post subject: | Re: I cant find one error in my program | ||
One thing I want to say is this is why a indentation really helps in spotting these types errors. The indentation can make it much easier to spot where the error is since indentation is probably wrong starting there. If you can get a tool that will indent source code or just keep properly indenting code, it will make finding errors like these very easy to spot. While I can see you are indenting perhaps you should look over where braces match. Just my 2c ![]() The tool I use for indenting code is Astyle which works for C++ and some others. Here's a slightly more indented version to show you why it makes it easier.
Hopefully you'll get it. |
Author: | wtd [ Sun Nov 09, 2008 12:19 am ] |
Post subject: | RE:I cant find one error in my program |
It also helps if you use standard C++ instead of this bastardized C stuff. Also, if you have forward declared your functions, then your main function does not need to come at the end of the program. In fact, it probably shouldn't. |
Author: | HolyDude [ Sun Nov 09, 2008 4:34 am ] |
Post subject: | Re: RE:I cant find one error in my program |
gitoxa @ Sun Nov 09, 2008 9:57 am wrote: Quote: Line Number 67 : Declaration syntax error
This is a large clue. ![]() Actually, after going through it, there is another problem in the program that presents itself after you fix the current mistake you have. I'd post it but that'd be giving away your current problem. I just want this program working, at any adjustments made.. I dont know why, but I cant solve this error, please help... |
Author: | md [ Sun Nov 09, 2008 11:18 am ] | ||
Post subject: | RE:I cant find one error in my program | ||
Here is the list of things you need to fix 1) wrong includes 2) it seems the standard these days is to teach "using namespace ...", which apparently you mean to do but do not do. 3) only after fixing both those will it become apparent: (after compiling Saad's code, with modifications for previous two points - no difference in line number) Quote: text.cpp: In function `void search(int)`:
text.cpp:63: error: a function-definition is not allowed here before `{` token Incidentally, that line is
|
Author: | HolyDude [ Sun Nov 09, 2008 1:07 pm ] | ||
Post subject: | Re: I cant find one error in my program | ||
This is a more revised version which runs in dev C++ The problem is when I try to enter a new student details,it get messed up then. |