So I've been making a decently large single file program to simulate The Game of Life, and I think I have everything ready but for some reason im getting stuck in an infinite loop in a situation where the variable getting changed *shouldn't* be changed or atleast I certainly dont want it to be changed, the thing that's confusing to me is that the code run's fine (straight into an infinite loop mind you) but the debugger warns me of a syntax error near my if statement that compares a value within a char array with another char, when I watched the variables, one of the variables that denotes the position of the char within the array gets changed somehow during or after the if statement and I can't find any reason why it would happen and im very frustrated. Im going to give you the function itself (because the whole program is rather large) and try to explain the variables best as I can.
When the if statement executes l changes from whatever it was to a value of 0 and even sometimes 1 (which further confuses me).
To clarify the three functions within this function work correctly (I've checked them in the debugger) the problem is at the if statement (I originally didn't use l and p because they are redundant but it made tracking the unintended change easier for me).
Any help is vastly appreciated ( and yes I know there are no comments ), also this assignment is for a class so using certain things that might make this whole process easier are forbidden for me to use (I cant even use explicit pointers).
One thing to note - you are passing the same (not copy of) array temp each time the loop passes. If any of the elements of this array is changed in createPoint(), it stays that way for the next passing through the loop. I do not know if this function changes any of the values, but then, if it is not - why the hell bother with passing 8 elements, if we know they all start at value false.
Consider reinitializing tempinside the loop, not before.
Also - and I know it's far-fetched - but do the functions inside the loop take i and j by value, or maybe by reference (invocation would look the same, but behaviour would change drastically).
The functions take them by value, and again you're right about temp it should be initialized inside the loop, but im still unfortunately stuck inside an infinite loop and it has something to do with if (dis[l][p] == '*'). No error appears in the compilation of the program, but the debugger claims there is a syntax error "near" the if statement, and everytime the loop hits that statement "l" get's changed from whatever it was depending on the number of times the loop has passed to 0 or 1. The only reason it ever goes above 0 and 1 is because I reassign it to "j" each time. I don't understand why an if statement is changing a variable used to indicate a place within the array that is being compared.. how does that even happen? Am I missing some rule that relates back to C or something?
I figured it out!! It was a silly mistake by me, a typo within createPoint was setting temp to true.... Im not exactly sure how an out-of-bounds array would change "l" but once I fixed that it doesn't seem to get changed anymore and it would make sense that it was changing to 1 and 0 since temp is a bool, im not sure how I didnt expect something like that.
Sorry to bother you when it turns out I just hadn't inspected one of my functions hard enough.