The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
[OT]-"sprintf_s()" - (C) & (R) Symbol Characte
JeZ-l-Lee


Joined: 20 Sep 2009
Posts: 572
Location: Long Island, New York, United States, Earth
[OT]-"sprintf_s()" - (C) & (R) Symbol Characters?

Hi,

I was using Code::Blocks on Windows to build our game.
I recently changed to Microsoft Visual Studio Express 2013.

I've got everything working except the following:
I can't seem to print (C) and (R) symbol characters?

Here is the code:
Code:
char *copy = new char[2];
sprintf_s(copy, "%c", 0xA9); //<- error C2664: 'int sprintf_s(char *,size_t,const char *,...)' : cannot convert argument 2 from 'const char [3]' to 'size_t'
strcpy_s(visuals->VariableText, copy);


Any help would be appreciated, thanks!
[OT]-"sprintf_s()" - (C) & (R) Symbol Characte
Justin Coleman
Guest

Probably because that's not how you call sprintf_s. From the VS2013 help:
int sprintf_s( char *buffer, size_t sizeOfBuffer, const char *format [, argument] ... );


As you can see, the second parameter is supposed to be the length of the buffer, but you're omitting it entirely. The error message you quoted even shows you the parameter list for the function.





On Wed, Apr 22, 2015 at 11:42 AM, JeZ-l-Lee wrote:
Quote:
[OT]-"sprintf_s()" - (C) & (R) Symbol Characters?

Hi,

I was using Code::Blocks on Windows to build our game.
I recently changed to Microsoft Visual Studio Express 2013.

I've got everything working except the following:
I can't seem to print (C) and (R) symbol characters?

Here is the code:



Code:

char *copy = new char[2];
sprintf_s(copy, "%c", 0xA9); //<- error C2664: 'int sprintf_s(char *,size_t,const char *,...)' : cannot convert argument 2 from 'const char [3]' to 'size_t'
strcpy_s(visuals->VariableText, copy);




Any help would be appreciated, thanks!



JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org