Add something like
printf("%s\n", temp);

or use the debugger to step through the code and examine the variables as you execute each line of code.