Sorry for the delay, I went to sleep. :) Anyways, your problem is (I presume) that you enter a string instead of numbers when it asks you for a seed. That way scanf won't accept it and the whole string (I mean the part of the string which begins with a non-number) stays in buffer, which is then passed to the next scanf. So when it asks you for a seed and you enter for example 123hello, 123 is processed and "hello\n" stays in buffer. Then the game asks you for a direction and then 'h' is passed from buffer (why only 'h'? Because you are asking for a single character with %d). Then it checks if the game is over and since it is not, it loops again. Then it passes 'e' and so on.
So, in short, enter only numbers. But even so, the game will print the map twice. Why? :) Because if you enter 123, it actually stores "123\n" and '\n' is not a number again. So after the scanf which gets seed, you should have
getc (stdin);
to get rid of the '\n' from buffer. :) stdin stands for standard input.
EDIT: About scanf and passing a char array to it - let's have char array [10]. Now when you do array[0] = 'a', it's the exactly same thing as *array = 'a'. Similarily array[5] = 'b' is the same thing as *(array + 5) = 'b'. array[i] = 'c' is thus the same as *(array + i) = 'c'. This is why
scanf ("%s", name)
does the same thing as
scanf ("%s", &name[0])
. I did not "pass the actual variable," as you said, I did the same thing as you did - pointed to the beginning of the array. I think you can see now why it is better to write it the first way - it is shorter and cleaner. :)
About the for loops and declaring variables. There is no problem having for example
1 2 3 4 5 6 7 8 9 10 11
|
int i;
for (i = 0; i < 10; i ++) {
...
}
...
for (i = 0; i < 20; i ++) {
...
}
|
As you can see, you can still use the single variable i, because you always set its value again in a for loop header. Some compilers won't even let you compile your program if you declare a variable inside a for loop header, some will give you a warning.