![]() |
| ||
| explanation for source code of printf /*/* * if you compile this file with * gcc -Wall $(YOUR_C_OPTIONS) -DTEST_PRINTF -c printf.c * you will get a normal warning: * printf.c:214: warning: spurious trailing `%' in format * this line is testing an invalid % at the end of the format string. * * this should display (on 32bit int machine) : * * Hello world! * printf test * (null) is null pointer * 5 = 5 * -2147483647 = - max int * char a = 'a' * hex ff = ff * hex 00 = 00 * signed -3 = unsigned 4294967293 = hex fffffffd * 0 message(s) * 0 message(s) with % * justif: "left " * justif: " right" * 3: 0003 zero padded * 3: 3 left justif. * 3: 3 right justif. * -3: -003 zero padded * -3: -3 left justif. * -3: -3 right justif. */ #endif |
| ||
| Re: explanation for source code of printf now that you have posted all that code, what, if anything, is your question? |
| ||
| Can any one help me to solve this problem Normally we use printf to print a statement in C-Language,but how can we print a statement without using a printf in LINUX. Could Some one tell me the addresses of the output window in LINUX,where we view the output of any C-Program. |
| ||
| Re: explanation for source code of printf > but how can we print a statement without using a printf in LINUX. Well given say char *p = "this is a message"; You can have puts(p);or while ( *p ) putchar(*p++);or write(1,p,strlen(p));> Could Some one tell me the addresses of the output window in LINUX There's no such thing. The whole of Linux is based on file descriptors, which could be anything from - a real terminal - a pseudo terminal - a file - another program. If you're thinking of DOS, where you could cause things to appear on screen simply by writing some data to say b800:0000, then you're out of luck. There is no equivalent of that in Linux, or any other modern OS for that matter. |
| ||
| Re: explanation for source code of printf In *nix you can use curses library which allows you to put characters on the screen in random locations. I also did it over 10 years ago using termio but I don't remember how I did it any more. |
| ||
| Re: explanation for source code of printf I would thank you for replying to my query ,Could you please give the source code for system call function write(). |
| ||
| Re: explanation for source code of printf I would imagine it's somewhere in the source code nearby where you found the source code for printf() Where exactly is this question leading? |
| ||
| Re: explanation for source code of printf I want to know how the values are printed on the output window i.e the code for write() or printf(). |
| ||
| Re: explanation for source code of printf What difference does it make how exactly it is done? The C standards do not dictate how its done so each compiler might do it differently. The characters are ultimately sent to the os and let the os display then on whatever terminal(s) happens to be attached to the computer. If you really think you can read and understand the source code for write then you can get gcc version from www.gnu.org where they will give you free all the source code for their compiler. But be prepared for heavy-duty reading which very vew if anyone will help you. |
| ||
| Re: explanation for source code of printf Thanks for the code. I was googl'ing for a solution and this was just what I needed. |
| All times are GMT -4. The time now is 1:06 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC