working of printf()


 
Thread Tools Search this Thread
Top Forums Programming working of printf()
# 8  
Old 08-28-2010
In most library implementations, printf is simply a wrapper around another another version of printf which takes a va_list as an argument. No checking is done on the variable arguments "..."

For example, here is what AT&T's AST libast does:
Code:
int
printf(const char* fmt, ...)
{
        va_list args;
        int     v;

        va_start(args, fmt);
        v = sfvprintf(sfstdout, fmt, args);
        va_end(args);
        return v;
}

This is why you get the observed behavior.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Disk Space Utilization in HTML format working in one environment and not working on the other

Hi Team, I have written the shell script which returns the result of the disk space filesystems which has crossed the threshold limit in HTML Format. Below mentioned is the script which worked perfectly on QA system. df -h | awk -v host=`hostname` ' BEGIN { print "<table border="4"... (13 Replies)
Discussion started by: Harihsun
13 Replies

2. Shell Programming and Scripting

Automating pbrun /bin/su not working, whenever manually it is working using putty

I am trying to automate a script where I need to use pbrun /bin/su but for some reason it is not passing thru the pbrun as my code below. . ~/.bash_profile pbrun /bin/su - content c h 1 hpsvn up file path I am executing this from an external .sh file that is pointing to this scripts file... (14 Replies)
Discussion started by: jorgejac
14 Replies

3. Shell Programming and Scripting

Printf %T not working

Dear All, this script was working well enough few days back. Now it started acting up. Could anyone please throw some lights about what may be the reason for it's not working. ts=$( printf "%(%s)T" "now" ) under debug mode this is what I get printf "%(%s)T" "now" ++ printf '%(%s)T'... (4 Replies)
Discussion started by: manas_ranjan
4 Replies

4. Shell Programming and Scripting

Crontab is not working in printf

hi, i have a script as: printf '%s -> %s\n' "$(date '+%Y-%m-%d %H:%M')" "$(/opt/gcsw/status -ne | fgrep 'State:2' | wc)" which gives output as: 2013-01-18 13:00 -> 80 480 6529 and it is working fine. now I want to put this into cronjob and write the output to a file in every 5... (7 Replies)
Discussion started by: gc_sw
7 Replies

5. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

6. UNIX for Dummies Questions & Answers

Qsub and printf

Hello, I have some issue with qsub and the standard output : I launch a script that "echoes" the string "abc" and then executes a C program in which I print informations with the printf function ; the .o file contains "abc" but not the information displayed by printf. I also tried... (0 Replies)
Discussion started by: Shaderw
0 Replies

7. UNIX for Dummies Questions & Answers

Need help with printf

Hi, I have just completed my first script (:D) and now i just need to format it with printf. This is what I have: #!/bin/ksh TOTB=0 TOTF=0 TOTI=0 HOST=`hostname` echo " FSYSTEM BLKS FREE INUSE MOUNTEDON" df -m | grep -v ":"|grep -v Free|grep -v "/proc"| while read FSYSTEM... (2 Replies)
Discussion started by: compan023
2 Replies

8. Shell Programming and Scripting

printf problem

I have the following code: $ awk '{ printf "%-10s %s\n", $1, $2, $3, $4, $5, $5, $6 }' file i can only print the first 2 elements ($1,$2). How can i print all the elements to appear like this: aardvark 5555553 jhfjhfjkg efiigig ejkfjkej wjkdjk alpo-net 5553412 ... (2 Replies)
Discussion started by: DDoS
2 Replies

9. Shell Programming and Scripting

printf

How to print output in following format? A..................ok AA................ok AAA..............ok AAAAAA........ok "ok" one under one (4 Replies)
Discussion started by: mirusnet
4 Replies

10. Programming

printf

What is the output of the following program considering an x86 based parameter passing sequence where stack grows towards lower memory addresses and that arguments are evaluated from right to left: int i=10; int f1() { static int i = 15; printf("f1:%d ", i); return i--; } main() {... (2 Replies)
Discussion started by: arunviswanath
2 Replies
Login or Register to Ask a Question
XPRINTF_EXEC(3) 					   BSD Library Functions Manual 					   XPRINTF_EXEC(3)

NAME
asxprintf_exec, dxprintf_exec, fxprintf_exec, sxprintf_exec, xprintf_exec, vasxprintf_exec, vdxprintf_exec, vfxprintf_exec, vsxprintf_exec, vxprintf_exec -- execute-only extensible printf execution SYNOPSIS
#include <printf.h> int asxprintf_exec(char ** restrict ret, printf_comp_t restrict pc, ...); int dxprintf_exec(int fd, printf_comp_t restrict pc, ...); int fxprintf_exec(FILE * restrict stream, printf_comp_t restrict pc, ...); int sxprintf_exec(char * restrict str, size_t size, printf_comp_t restrict pc, ...); int xprintf_exec(printf_comp_t restrict pc, ...); #include <stdarg.h> int vasxprintf_exec(char ** restrict ret, printf_comp_t restrict pc, va_list ap); int vdxprintf_exec(int fd, printf_comp_t restrict pc, va_list ap); int vfxprintf_exec(FILE * restrict stream, printf_comp_t restrict pc, va_list ap); int vsxprintf_exec(char * restrict str, size_t size, printf_comp_t restrict pc, va_list ap); int vxprintf_exec(printf_comp_t restrict pc, va_list ap); DESCRIPTION
These functions are execute-only, extensible printf (see xprintf(5)) variants, taking a printf_comp_t structure created by the format string compilation routine new_printf_comp(3). All these variants behave like their normal printf counterparts (see printf(3)) without 'x' and ``_exec'' in the name (except sxprintf_exec() and vsxprintf_exec() behave like snprintf() and vsnprintf(), respectively). SEE ALSO
printf(3), xprintf_comp(3), xprintf(5) Darwin Aug 19, 2012 Darwin