469,636 Members | 1,544 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,636 developers. It's quick & easy.

format specifier

HI,

What does these mean -

- " lx%08lx "
- " %1024[^\n]%*[^\n] "

I have seen them being used in printfs. When do you exactly write/use these ?

Thx in advance
- Ravi
Nov 13 '05 #1
2 9735
"Ravi Uday" <ra*****@yahoo.com> wrote in message
news:ec**************************@posting.google.c om...
| What does these mean -
|
| - " lx%08lx "

In a printf call:
- the leading lx will be written literally (as is).
- %08lx will print 8 hexadecimal digits with leading zeroes.

| - " %1024[^\n]%*[^\n] "

This looks like it belongs in a scanf call:
- up to the following 1024 characters that do not match the newline
character will be read into the char buffer passed as a parameter.
All the following character up to the newline character are
discarded.

.... if I'm not mistaken.

| I have seen them being used in printfs.
| When do you exactly write/use these ?

When you are sure that all the potential readers of your code
understand the C format specifiers in depth.

A lot can be done with C format specifiers (and even more than
before in the C99 standard). They allow concise parsing of
input and formatting of output text. But they tend to be
tricky and error prone...
Cheers,
--
Ivan Vecerina, Dr. med. <> http://www.post1.com/~ivec
Nov 13 '05 #2
In <3f********@news.swissonline.ch> "Ivan Vecerina" <iv**@myrealbox.com> writes:
"Ravi Uday" <ra*****@yahoo.com> wrote in message
news:ec**************************@posting.google. com...

| I have seen them being used in printfs.
| When do you exactly write/use these ?

When you are sure that all the potential readers of your code
understand the C format specifiers in depth.


Which means never, considering the impossibility of acquiring such a
certitude ;-)

printf/scanf are basic features of the C language. Whoever deals with a
piece of production code is supposed to be familiar with them.

It makes no sense to avoid such features *only* because an incompetent
programmer might end up reading your code.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by John Lenton | last post: by
reply views Thread by Josiah Carlson | last post: by
4 posts views Thread by Peter Ammon | last post: by
6 posts views Thread by John L. | last post: by
5 posts views Thread by siliconwafer | last post: by
4 posts views Thread by ThisBytes5 | last post: by
18 posts views Thread by Money | last post: by
2 posts views Thread by =?Utf-8?B?Um9ubmllIFNtaXRo?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.