Quote:Original post by Zahlman
The original code has bugs, which Xai and many others pointed out, and the suggested inclusion cannot prevent those problems.
The statement "meh = &blah[0];" (which is equivalent to "meh = blah;") does not do what the OP wants - it will make meh point at the array data, when the OP clearly wants meh to point at a separate copy of that data.
"adding it before the sprintf" is just silly, as a result - why make a pointer point at an array and then sprintf the array contents to the location indicated by the pointer? The sprintf becomes a no-op. Of course, it will still end up outputting the desired text and will therefore "work perfectly" - except that it won't, because the previous assignment of the string literal to the char array is still wrong!
I made an attempt to demonstrate that I know whereof I speak. You are hereby challenged to follow suit.
There is no need to challenge, because I just misunderstood. But the way you replied at first is easy to misunderstand, you could've said that whole thing earlier. Anyway, I thought you were saying the syntax is wrong and bad, and did not know you were talking about the result not being the OPs wanted result.
Cya!