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 Reply Children
  • What it does is clearly answered in the manual.

    The reason for it has been clearly answered in this thread.

  • have you bother to read the threads above? they clearly answer your question. to make a long story short, just google 'sprintf'. you will be amazed to find that it has nothing to do with LCDs (nor with LSDs...), serial ports and alike.

  • "i meant what is usage of the fuction in application"

    You use it exactly as described in the manual;
    The manual even includes an example of its usage.

    http://www.keil.com/support/man/docs/c51/c51_sprintf.htm

    Have you actually bothered to look at the manual yet??

    As previously stated, this has nothing specifically to do with Keil, nor the 8051, nor embedded systems - it is perfectly straightforward, standard 'C'.
    Therefore, if you need further examples, just look in your 'C' textbook, or any other standard 'C' tutorial.

    "use it with memory or lcd or serial port other things ??"

    Yes, it could possibly find application in all those scenarios; in fact, anywhere that you want to place formatted text into a buffer = just as it says in all the Manuals, textbooks, etc...

  • Sure you can send it to and LCD, and EEPROM. Modify the buffer then send it to the Serial Port.

    It is just another library function. Maybe you need it maybe you do not.

  • In words of one syllable YES
    You can use it for an innumerable number of things.

    The important thing is to start with what you need (IE define a problem) then look at what you have (IE what C functions that may be used to meet said need).

    I use printf to dumb data to a serial port print formated data to a graphic LCD (lots of fancy stuff processing said data underneath granted), and dump memory information (in my case contents of specific data structures). It can be used with pretty much ANYTHING that needs formated text, that is what it was designed and intended to be used for.

    The limitation of what it can be used for however is what you need to do.

    Stephen