why string concatenation getting strange result in c++? -
i trying concatenate 2 strings in c++:
"g1-2" + "-%02d.jpg" and getting following result:
g1-2-1537817269.jpg why isn't result this: "g1-2-%02d.jpg"
wild guess!
you're printing concatenated string by
printf(str); where str "g1-2-%02d.jpg"
printf("g1-2-%02d.jpg"); ^^^^ // but, corresponding integer in following? as can see there's %02d in string , printf seek integer argument. can not find , undefined behavior occurs. in best situation prints out random value string.
if guess true, try print string in form:
printf("%s",str);
or use double % chis mentined:
"g1-2-%%02d.jpg"
Comments
Post a Comment