char szHead[10]; char szDst[256]; strcpy(szHead,"Head"); strcpy(szDst,"adfasdfasdfddfasdfasd"); sprintf(szDst,"%s\n%s",szHead,szDst); 本来想在szDst前加个头,可是结果却是szDst变成了"Head\nHead\nHead\n...... what's the problem of these statement?
The sprintf function formats and stores a series of characters and values in buffer. Each argument (if any) is converted and output according to the corresponding format specification in format. The format consists of ordinary characters and has the same form and function as the format argument for printf. A null character is appended after the last character written. If copying occurs between strings that overlap, the behavior is undefined.