This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

what is the difrrent between printf & sprintf and scanf & sscanf

Hello to All

what is the different between printf & sprintf and scanf & sscanf

I read the help but i dont understand it


printf("Hello world \n");

aprintf("Hello world \n");
------------------------------

int k;
scanf("%d",k);

sscanf("%d",k);

.

Thanks = 10x

Mayer

Parents
  • "i understand what the fuction sprintf it does"

    That's not what you said in your original post!

    "but for what it good for ???"

    It's a standard 'C' function - so you should be able to answer that by looking in any 'C' textbook!

    This has nothing specifically to do with the 8051 nor Keil - it is plain, vanilla, standard 'C'.

    It is good for doing exactly what the manual says that it does:

    "The sprintf function formats a series of strings and numeric values and stores the resulting string in buffer."

    So, when you want the resulting string stored in a buffer - rather than sent to stdout - that's when you would use sprintf.

    If that's not clear enough for you, the manual goes on to explain:

    "This function is similar to the printf routine, but it stores the formatted output in buffer rather than sending it to the output stream."

Reply
  • "i understand what the fuction sprintf it does"

    That's not what you said in your original post!

    "but for what it good for ???"

    It's a standard 'C' function - so you should be able to answer that by looking in any 'C' textbook!

    This has nothing specifically to do with the 8051 nor Keil - it is plain, vanilla, standard 'C'.

    It is good for doing exactly what the manual says that it does:

    "The sprintf function formats a series of strings and numeric values and stores the resulting string in buffer."

    So, when you want the resulting string stored in a buffer - rather than sent to stdout - that's when you would use sprintf.

    If that's not clear enough for you, the manual goes on to explain:

    "This function is similar to the printf routine, but it stores the formatted output in buffer rather than sending it to the output stream."

Children
No data