473,385 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 10581
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: John Lenton | last post by:
Is there any reason python's printf-style formatting is missing the (C99) '%a' specifier? I'm sorry if this has been asked and answered before; I can't find it on google ('%a' is a very awkward...
0
by: Josiah Carlson | last post by:
Good day everyone, I have produced a patch against the latest CVS to add support for two new formatting characters in the struct module. It is currently an RFE, which I include a link to at the...
4
by: Peter Ammon | last post by:
Does anyone ever write the arguments to printf()-like functions under the corresponding format specifier? printf("My name is %s and I am %u years old\n", name, age); If the arguments...
6
by: John L. | last post by:
I've seen several postings asking this, but no simple, clear answer. My C language reference book is deficient in this area. If I short i = 0; printf(">%2x<",i); I might resonably expect...
5
by: siliconwafer | last post by:
Hi All, What does a 'format specifier' do? Suppose I do, int a = 43; //decimal number printf("%x",a); I will get hex equivalent of 43. Does the format specifier do an implicit "decimal to hex"...
4
by: ThisBytes5 | last post by:
I need to turn 40000 in to 40,000 for display. Is there a way to do this directly in the Gridview and I'm just not seeing it? or do I have to use a TemplateField and do my own Formatting? ...
18
by: Money | last post by:
Here in this thread http://groups.google.co.in/group/comp.lang.c/browse_frm/thread/c16d280238a95c9/e3b0dbf76f3e02e3?q=finding+endianness&rnum=1#e3b0dbf76f3e02e3 Tydr Schnubbis in 3rd reply used...
2
by: =?Utf-8?B?Um9ubmllIFNtaXRo?= | last post by:
Hello, I would like to be able to accept a format string in the form of say {0:D2} as an input from a dialog box, and then dynamically format the output string based on this new format...
7
by: codinginc | last post by:
Hi Everyone, Is it possible to insert format specifier in a form of variable. See example below Standard from char result; float fnum = 3.14159; sprintf( result, "%f", fnum );...
15
by: Andreas Eibach | last post by:
.... but I have an unsigned long value in the printf. This warning came when I used gcc 4.x to compile. .... unsigned long offset = 0; .... Well OK, an "easy" way would be instead of printf...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.