473,385 Members | 1,867 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.

pls abt printf

guys i'm really pleasing to you .. please anyone knows abt the printf stmt (internal working) please post your ideas..
waiting for your reply..

thanks in advance..
Oct 4 '06 #1
4 1576
Banfa
9,065 Expert Mod 8TB
It is platform defined, that is each platform is free to do it anyway it wishes as long as it produces the correct result.

Why do you want to know this?
Oct 4 '06 #2
It is platform defined, that is each platform is free to do it anyway it wishes as long as it produces the correct result.

Why do you want to know this?
i need to know how it finds place holders and variable, and how it converts the variable to place holders datatype, then how the excess args are ignored....
Oct 4 '06 #3
Banfa
9,065 Expert Mod 8TB
Well most of the implementations I have seen/written use a char * to iterate down the string picking out the % characters and parsing the characters that follow.

This lets you pick out the data from the parameters using

va_start
va_arg
va_end

macros defined in stdarg.h but it helps that in the absence of a string prototype variables are passed by default types (i.e. char and short are passed as int)

Ignoring extra data is easy, just don't access it.
Oct 4 '06 #4
Well most of the implementations I have seen/written use a char * to iterate down the string picking out the % characters and parsing the characters that follow.

This lets you pick out the data from the parameters using

va_start
va_arg
va_end

macros defined in stdarg.h but it helps that in the absence of a string prototype variables are passed by default types (i.e. char and short are passed as int)

Ignoring extra data is easy, just don't access it.
THANK YOU VERY MUCH.. I HAVEN'T EXPECTED SUCH REPLIES FROM FORUMS.. THIS IS MY FIRST FORUM.. REALLY HAPPY..
THANK YOU AGAIN..
Oct 4 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Grumble | last post by:
Hello, I have the following structure: struct foo { char *format; /* format string to be used with printf() */ int nparm; /* number of %d specifiers in the format string */ /* 0 <= nparm <=...
8
by: aditya | last post by:
hi, Can anybody please tell me that how the following printf(...) statement works- main(){ int d=9; printf("%d",printf("%d")); return 0;
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
188
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
29
by: whatluo | last post by:
Hi, c.l.cs I noticed that someone like add (void) before the printf call, like: (void) printf("Timeout\n"); while the others does't. So can someone tell me whether there any gains in adding...
4
by: pai | last post by:
Hi , Can any one tell me how this statement of printf is behaving . how the last digit is printed int a=2,b=4,c=7; printf("%d",printf("%d %d:",a,b)); //answer to this was 2 4:3
11
by: timmu | last post by:
Someone asked me a question about integer division and printf yesterday, I tell him he should do a casting to float/double before you do any interger division. But he doesn't think so, so I try...
19
by: RedDevilDan | last post by:
I am working on a Memory Footprint Reduction project. I came across an idea to disable all printf statements so that less memory is required. In addition, when there is no single printf statement,...
34
by: Old Wolf | last post by:
Is there any possible situation for printf where %hd causes a different result to %d, and the corresponding argument was of type 'short int' ?
1
by: linq936 | last post by:
Hi, I read in many places that the string to be outputted by printf() must be ending with newline, for example, it should be printf("Hello World.\n"); instead of printf("Hello World.");
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.