extern long nsprintf (char *str, unsigned long ullen, const char *str, char *fmt, ...);
This function is a private implementation of H3C, and the difference from sprintf is that the function return value is the length of the source string. The maximum assembly length is ullen, and the trailing string does not automatically add "/0"
The non-applicable method of the function:
nsprintf (szUserName, sizeof (szUserName), "ABCDEFG");
It is not allowed to use a constant string as an entry parameter in a function. The reason is that the constant string needs to consume local storage space, you can define the required output string as a global variable, and change the input parameter to the first address of the string.
nsprintf (szUserName, sizeof (szUserName), pstexecdata->szusername);
This usage is also inappropriate, because the string pstexecdata->szusername itself may have%s formatted characters, the consequences of how to be determined.
The correct usage is:
nsprintf (szUserName, sizeof (szUserName), "%s", pstexecdata->szusername);
You can define lint rules to help check
Definition rule : lintheader.h
extern long sprintf (char *str, const char *str, char *fmt, ...);
extern long nsprintf (char *str, unsigned long ullen, const char *str, char *fmt, ...);