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.
I'm trying to pad\justify my text such that everything aligns properly. Can I do this from within sprintf? I've tried all kinds of combinations within the format string. Basically, this is the output I would like: #001 #002 #003 .... #010 etc
unsigned char num; unsigned char buf[20]; num = 0x01; sprintf(&buf[0], "#%bU", num);
I have stared at the manual's printf description for quite some time and haven't seen the answer that I'm looking for. I'll check some of my C books. But in the meantime, as a forum user, sharing ideas or discussing that which others may not understand\find is the sole purpose of a forum. Its a great way to get a quick answer someone may already know. So I encourage you, Mr. Neil, to participate if possible. Thanks James
"But in the meantime, as a forum user, sharing ideas or discussing that which others may not understand\find is the sole purpose of a forum." The purpose of *this* forum is to discuss Keil tools. ANSI C is very well catered for in other forums, not to mention some excellent books. If you want a clear, complete and concise description of the printf() format strings I would recommend "C: A reference manual" by Harbison and Steele. If you want to discuss ANSI C, I would recommend comp.lang.c on usenet. "Its a great way to get a quick answer someone may already know" printf() format strings are quite complex. In spite of having been a C programmer for 14 years I still regularly have to refer to the manual. As you'll see from Jon Ward's response, he too had to refer to the manual to answer this question. All you are really achieving by asking questions that are answered in the manual is wasting everyone's time. "So I encourage you, Mr. Neil, to participate if possible." Mr. Neil participates a great deal in this forum, but he understandably gets a bit irritated when people ask questions that are better answered by looking in the manual. So, I encourage you, Mr. Corbin, to Please read the manual. Stefan