The blind leading the blind....
Advice from the one eyed King -
@Earth angel. - you need to make your string declaration static like so
Otherwise once the functions completes, the string is no longer allocated and thus it's pointer is invalid. Sean's code is correct only because he's returning a pointer to a constant string. It won't work for variables.Code:static char string[50];
Also when you enter your while loop for the first time, you're testing it before it's been initialised. Either initialise it first, or perhaps use a do..while loop.