Code:*cols = 2; else if (!table[*rows][*cols]) { table[*rows][*cols] = 1; return TRUE; }
Code:*cols = 2; else if (!table[*rows][*cols]) { table[*rows][*cols] = 1; return TRUE; }
~flood
More code please. Just because it says "parse error before else" doesn't mean the error is directly before the else.
My best code is written with the delete key.
I have hundreads of lines before that piece of code. It compiles well if I just comment *cols = 2;
~flood
before an else if statement, you need either an if statement, or another else if statement. Currently, you appear to have:
before your else if block, but it is not inside of an if or else if block.Code:*cols = 2;
>I have hundreads of lines before that piece of code.
That's nice, why not just limit yourself to the first five lines before that assignment if you're afraid you might get carried away and post it all.
>It compiles well if I just comment *cols = 2;
You don't quite understand. I don't care. I want to see what you have before that line because you've given a partial snippet. I could paste that snippet into a test program and get it to work without any modification, that's why I want to see something that is proof of an error.
My best code is written with the delete key.
Yea you are right. Why does it work like that?Originally Posted by bithub
sorry about that.That's nice, why not just limit yourself to the first five lines before that assignment if you're afraid you might get carried away and post it all.
~flood
>Why does it work like that?
Your other option is to scrap everything and start over.
Curious as to what your first option was? Well, so is your compiler, so anytime you have an else clause, you need an if clause as well.
>but it is not inside of an if or else if block
A hint for future replies: No matter how sure you are of your assumption, it's still an assumption. It could be that the snippet just had bad formatting, which is why I was pushing for a more complete example. I don't know about you, but I'd rather be 100% sure of the problem than to be 99% sure of the problem and have it turn out to be that odd 1%.
My best code is written with the delete key.
Given his error and his code, my only assumption was that the code he posted was the actual code he was using in his project. If I had to start second guessing every bit of code posted here (Is that actually what your code looks like, or did you mess up the copy/paste), then I would quickly become frustrated.
If I keep assuming the error they post is the actual error they are getting, and the code they post is the actual code they are using, then I can sleep soundly at night knowing that the odd 1% is on them, and not me
>>I could paste that snippet into a test program and get it to work without any modification
eh, how?
I did have an if statement before the else if it's just that *cols = 2; was between the two.Your other option is to scrap everything and start over.
Curious as to what your first option was? Well, so is your compiler, so anytime you have an else clause, you need an if clause as well.
~flood
><snip> then I can sleep soundly at night knowing that the odd 1% is on them, and not me
Whatever floats your boat. I'm far more anal.
>eh, how?
This is a direct paste with no changes into a test program. It compiles cleanly, and in a real program, the if statements are plausable because we had no idea what the logic for the program was.
>it's just that *cols = 2; was between the two.Code:#define TRUE 1 int main ( void ) { int table[3][3] = {0}; int r = 0, c = 0, *rows = &r, *cols = &c; if (table[*rows][*cols]) *cols = 2; else if (!table[*rows][*cols]) { table[*rows][*cols] = 1; return TRUE; } }
That breaks the if chain, so you were effectively trying to start a new if chain with an else if.
My best code is written with the delete key.
>> Whatever floats your boat. I'm far more anal.
>> This is a direct paste with no changes into a test program.
Yeah, I guess I was thinking too much in context of the error he gave.
Are there any other statements between the if and else statements besides *cols = 2; ?
nopeAre there any other statements between the if and else statements besides *cols = 2; ?
~flood
Hey, I've got an idea. How about posting more code? I'm sure this is entirely original and no one's mentioned it, so I thought I'd take care of it.
-Govtcheez
[email protected]