user1409254
user1409254

Reputation: 49

c++/sprintf: unrecognized character escape sequence

How to avoid these sprintf warnings ?

C4129: '#' : unrecognized character escape sequence
C4129: ':' : unrecognized character escape sequence

sprintf(szBuf,"1312:%d\#%s\:",iVal,pUser)

Upvotes: 0

Views: 6706

Answers (1)

paxdiablo
paxdiablo

Reputation: 881573

If you want a literal \ in your strings, you should write it as \\.

The \ character starts an escape sequence and neither # nor : are valid as the second character. It's meant to allow for things like newline \n or tab \t.

Of course, if you don't wish to have \ in your resultant string, just remove it altogether.

Upvotes: 2

Related Questions