Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Loop problem

Author
Message
Vesper103
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Beloit WI
Posted: 24th May 2008 22:33
this is the last thing i thought id need help with >.> but I'm having problem with for loops. in specific with variable scope in for loops.

ive tried to include the variable offset 2 seperate ways:

way 1:



way 2:



the first one returns aroudn 6 errors all talking about "int unexpected" and "undeclared "offset""

the second gives 1 error in the X loop for "offset undeclared"

what am I doing wrong?

Your signature has been erased by a mod - please reduce it to 600x120
Vesper103
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Beloit WI
Posted: 24th May 2008 22:35
FIX: i found the problem with the second way.. spelling error. but the first one still wont compile....

Your signature has been erased by a mod - please reduce it to 600x120
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 24th May 2008 23:44 Edited at: 24th May 2008 23:47
That's because you have a comma after the initial condition on the outer loop...supposed to be a semi-colon. EDIT : I see what you are trying to do now, try this:
int y, offset = 0;

Or this:

int y, offset;

for (y = 0, offset = 0; etc.

I will again advise you not to declare variables with that type of scope. There is no real advantage to doing so, and it will continue to bite you until you only use them in the limited way that allows. They occupy space on the stack either way, unless they are declared at the global data scope, outside of any functions altogether. The most pain free and consistent way to declare local variables is at the top of the function.
Vesper103
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Beloit WI
Posted: 25th May 2008 00:43
okay thank you

Your signature has been erased by a mod - please reduce it to 600x120

Login to post a reply

Server time is: 2024-09-29 21:21:11
Your offset time is: 2024-09-29 21:21:11