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

Discussion in 'C Programming' started by varojee@gmail.com, Nov 20, 2006.

  1. Guest

    hi!
    can we use any function to display our input

    without using a " printf " function? does c support such this
    possibilities?
    ...
     
    , Nov 20, 2006
    #1
    1. Advertising

  2. santosh Guest

    wrote:
    > 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.
     
    santosh, Nov 20, 2006
    #2
    1. Advertising

  3. Rg Guest

    On Nov 20, 11:23 am, "" <> wrote:
    > 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
     
    Rg, Nov 20, 2006
    #3
  4. Je-Givara Guest

    santosh wrote:
    >
    > 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?
     
    Je-Givara, Nov 20, 2006
    #4
  5. santosh Guest

    Je-Givara wrote:
    > santosh wrote:
    > >
    > > 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?


    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. :)
     
    santosh, Nov 20, 2006
    #5
  6. Neil Guest

    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
     
    Neil, Nov 21, 2006
    #6
  7. Je-Givara Guest

    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?
     
    Je-Givara, Dec 1, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page