I have used this type of convention many times in my code in the past:
strcpy ( cTmpA, "hello" );
sprintf ( cTmpA, "%s world", cTmpA );
Recently I switched my legacy C compiler to Visual Studio 2005, and found I got a garbled string resulting from the above code. It then occurred to me that perhaps the behaviour of sprintf() is not rigidly defined where one of the inputs matches the output string.
Is the above code valid K&R C? If not, how do I find all the places in my code where this type of call to sprintf() has occurred?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…