Don't have enough context to evaluate that statement. |
Lines 30,48. If the user enters S, you will execute both iScience() and iSports(). I pointed this out to you once before. Lines 62-80. Ditto. |
|
|
}
|
|
identifier bScience cannot have a type qualifier |
Declaration missing ; at the end of the following code: |
|
|
|
|
|
|
|
|
Check the pairing of your braces in Quiz::Start
Only the call to clrscr() is conditional on the if.
|
Also note that in bScience, you still have a function declaration, not a function call.void quizComp(); |
quizComp();
only.As I have stated before, your indentation sytle is NOT helping you to find mismatched or unmatched {}. A good IDE should highlight paired {} for you. |
|
|
if
statement.they teach us in Turbo C++ only. I know compilers like Visual C++ highlight the brace pairs. |
|
|
const char *
The message says "Declaration terminated incorrectly". There is no declaration in that code snippet. You need to back up at least to the previous declaration. |
Line 4 is a problem. There is no condition or closing ) for the if statement. |
|
|
In thinking about your program, it occurs to me that you have 21 functions that are nearly identical (7 subjects x 3 levels). The only thing different between those 21 functions is the name of the question and answer files. That is what arguments are for. Write ONE function and pass the name of the question and answer files as arguments to that function.
|
|
|
.c_str()
do? .c_str()
to something simpler which I can understand clearly. I've not learnt about it.Above all is this code to small the length of my program code? |
|
|
I don't understand what you're asking. |
|
|
f3.open(quest_fn);
|
|
I am asking that why there is a need to write the function you gave me above? |
The format of code I'm writing isn't suiting you? |
I can't change the algorithm of the program that I've thought of. |
Please, don't provide me with the code you gave. |
Sorry, but I can't use f3.open(quest_fn); |
I repeat my query, of why I'm getting Declaration terminated incorrectly in the code: |
Sorry, but I can't use f3.open(quest_fn); |
Why not? |
And I repeat me previous response. There is no declaration in that snippet. Your problem is BEFORE that snippet. There is a problem with that if statement. Your two variables names don't agree, but that is not the cause of the error you're exepriencing. Check any preceding declarations for a missing ; |
if
statements for Beginner, Intermediate and Expert it didn't gave me that error!just tell me one thing, how does that function works? |
while (f3)
tests that the status of the ifstream is good. Testing eof() is not the best practice. Note that your bArts() above reads the entire file, stopping only when eof is encountered. This results in only the last question in the ch1 buffer. Sorry, but I can't use f3.open(quest_fn); Why not? Because I haven't been taught of this type of file opening method. |
const char *
argument. There are many ways to supply such an argument. Here the filename variable contains the literal string and the variable is passed to open. This only difference in what I suggested is that filename is an argument and not a local variable.
|
|
const char *
bScience()
and bArts()
functions and instead of them (and others) I should write the AskQuestions()
function. while (f3)
statement should follow for f4 also?now I should delete my bScience() and bArts() functions and instead of them (and others) I should write the AskQuestions() function. |
|
|
1. What about the name of the files bScQues.txt, bArtQues.txt, bScAns.txt and bArtAns.txt? How can your quest_fn and answer_fn open them? How should I modify these text files? |
That is no different that passing a literal string to open. open expects a const char * argument. There are many ways to supply such an argument. Here the filename variable contains the literal string and the variable is passed to open. This only difference in what I suggested is that filename is an argument and not a local variable. |
3. Are f3 and f4 streams you declared here http://www.cplusplus.com/forum/beginner/147294/3/#msg791044 are for all subjects/levels? |
That is up to you. If you follow my suggestion, then yes, AskQuestions() replaces your 21 individual functions. |
2) There is the possibility the open at line 10 or the getline at line 16 could fail. It is best practice to account for that possibility. |
Why? Still confused.. |