We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, I am trying to create a string with a variable of type long, using sprintf.
char command [20]; long ofs = 363080; sprintf (command, "VAL=%d", ofs);
I only looked in a standard C-manual, where there's no such thing as an L Hmm... I think you need to throw that manual away and get a proper one! My ancient K&R (2nd Edition, 1988) says, "Between the % and the conversion character there may be ... an h if the integer is to be printed as a short, or l if as a long" It doesn't mention if the h and l are case-sensitive, but in C51 they certainly aren't (I prefer to use the uppercase L, as lowercase l looks too much like the digit 1 in many fonts) Note that K&R also says that printf, "will get confused, and you will get wrong answers, if there are not enough arguments or if they are the wrong type" (my emphasis)