c++ - wsprintf() crashes my application -


i'm new site, if wrong in first post, please don't take hard on me.

here goes nothing...

in application, have following code:

wsprintf(hardware_info, "%ul+%ul", dwgpu, dwcpu);

hardware_info stored lpstr, , passed reference parameter function contains line (e.g. void do_something(in lpstr out){})

dwgpu , dwcpu dword or ul, unsigned long data types.

when application executed crashes right after executing above line of code (note, doesn't passed line). can explain me problem is?

edit:

i've fixed issue. believe more of logical error. confused %ul thought stood unsigned long, though through research i've learned it's %lu, strangely enough.

thanks contributed this, it's helped thoughts going.

well, firstly, if hardware_info lpstr, why using wsprintf? wsprintf lptstr. lpstr "regular" char pointer supposed work sprintf. format string regular string, supposed work sprintf. code compile , work (i.e. wsprintf), if project set narrow-character strings, still there's no logic in using wsprintf here.

secondly, i'd guess failed allocate memory hardware_info or did not allocate enough. might caused code crash.