August 6th, 2003, 03:05 PM
Messed up string output in C
I am a newbie working with strings in C, and I have ran into this problem where the rear part of the string that is printed (using printf() ) is messed up.
char *finalExp = Pop(&exps);
I am using a stack that stores pointers to strings, and Pop(stack *s) operation pops and returns the top item of the stack.
.....(out3val)) & ((next(out2val)) = (out2à`ÿ¿à`ÿ¿)))
but it should be:
......(out3val)) & ((next(out2val)) = (out2val)))))))
What could be the cause for this problem? Is there any way to fix it?
Thank you in advance.
August 6th, 2003, 10:00 PM
Well, I dont see any problem in the code except that the size of the char array in the pop function may be less and hence it might be returning you the garbage at the end.