i have been working on this bug for ages in my level editor's load(); function
and cant seem to fix it infact the ony thing i managed to make it do is 1 read the executeble program!!!(itsself)
and
2. read from this weird C:\Windows\Sxs directory
num
Maximum number of characters to be copied into str (including the terminating null-character).
16 17
fgets(ch, sizeof ch, fp); // some people also do:
fgets(ch, 255, fp); // hard-coded value of 255, not recommended
That said, there are plenty other places for your load() function to fail.
Maybe Set_Map() fails. Maybe Set_walls() fails. You must check them all for bugs.
i had the 2nd parameter of fgets set to the size of my ch[] array before but it did not work
i can print out ch[] and it shows the contents of the file fine its just setting it to
the Map.Map[][] 2d array that i cant do for some reason i even tried directly assigning it and i failed!!!
Well I see that you are incrementing k without having initialized it.
Variables which are not initialized (or assigned a value to) before their value is used are said to hold "garbage".
In your case, k is not guaranteed to hold 0 (you rely on this for k++ to work correctly).
1 2 3 4 5 6 7
void load()
{
short i;
short j;
short k = 0; // initialize it
// ...