can we use such function to display input without using "Prinf" ?

V

varojee

hi!
can we use any function to display our input

without using a " printf " function? does c support such this
possibilities?
...
 
S

santosh

hi!
can we use any function to display our input

without using a " printf " function? does c support such this
possibilities?
..

Yes. Use the standard fprintf(), vprintf(), vfprintf(), puts(),
fputs(), putchar(), putc(), fputc(), or write your own.
 
R

Rg

hi!
can we use any function to display our input
without using a " printf " function? does c support such this
possibilities?
..

Standard C includes puts, fprintf, fputs, putchar and fputc which can
be used to print text into stdout or other specifi file streams.

Rg
 
J

Je-Givara

santosh said:
Yes. Use the standard fprintf(), vprintf(), vfprintf(), puts(),
fputs(), putchar(), putc(), fputc(), or write your own.

could you show me an example using
your own function?
 
S

santosh

Je-Givara said:
could you show me an example using
your own function?

As such custom functions are usually very platform specific, it would
not be topical for this group. However, if you _really_ want to see
such code, try asking Mr. Navia nicely. He's in a very OT mood right
now. :)
 
N

Neil

(e-mail address removed) wrote
hi!
can we use any function to display our input

without using a " printf " function? does c support such this
possibilities?

Yes, as many people know this topic is covered in detail in The C
Programming Language (2nd Edition) by Brian W. Kernighan, and Dennis
Ritchie, there is an example in the book and they explain how this
accomplished using a function.

Neil
 
J

Je-Givara

void minprintf (char *fmt, ... )
{
va_list ap;
char *p, *sval;
int ival;
double dval;
va_start (ap, fmt);
for(p=fmt; *p;p++)
{
if (*p != '%')
{
putchar (*p);
continue;
}
switch (*++p)
{
case 'd': ival = va_arg(ap,int);
printf("%d",ival);
break;
case 'f': dval = va_arg (ap, double);
printf("%f",dval);
break;
case 's': for (sval = va_arg(ap,char *);*sval;sval++)
putchar (*sval);
break;
default: putchar(*p);
break;
}
}
va_end(ap);
}

void main()
{
.....
}

so this a code and what shall we write in the Main program?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top