Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

where are the format specifiers implemented/defined in the c language?

i have been working in c for a couple months now and it has never come to my mind to check where actually the format specifiers implemented/defined in the c language format specifiers like :

%f
%d
%p
%s
#include <stdio.h>

int main(){
    printf("%f",7.8);
}

and so on i am asking you stackoverflow developers about these format specifiers i know these format specifiers are meant to be used with stdio.h but my question is where are they implemented/defined in c ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

where are the format specifiers implemented

They are implemented in the specific implementation source code of printf you are using. There are many implementations of prinf and implmentation of C standard library – https://en.wikipedia.org/wiki/C_standard_library#Implementations. You are using one of them.

Some are easier to read – https://github.com/eblot/newlib/blob/master/newlib/libc/stdio/vfprintf.c#L1220 . Some are very hard to comprehend and have been optimized through decades – https://github.com/lattera/glibc/blob/master/stdio-common/vfprintf.c#L293 .

defined in the c language?

printf format specifiers are "defined" – standardized, specified – in the C language standard. The draft of the standard we are using online you can read about them here https://port70.net/~nsz/c/c11/n1570.html#7.21.6.1p1 . But cppreference https://en.cppreference.com/w/c/io/fprintf is friendlier and much better formatted to read than dry standard.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading