/ ***********************************************************************
*
* Purpose: Program to demonstrate the 'sprintf' statement. This example
* is a bit lame as the same effect can be seen with a 'printf'.
* But, it does show a string being built and passed into a
* function.
* Author: M J Leslie
* Date: 10-Jul-94
*
************************************************************************/
#include <stdio.h>
main()
{
int i=1; /* Define an integer variable. */
char message[80]; /* Text string */
/* format text and put into 'message' this a great
* improvement over using 'strcpy' and 'strcat' to
* build a text string.
*/
sprintf (message, "i is %i", i);
/* I may be stating the obvious but a '\0' is
* put on the end of the string. */
puts(message); /* Display message */
}
| file: /techref/language/ccpp/cref/EXAMPLES/sprintf.c, 0KB, , updated: 1998/3/18 10:29, local time: 2010/3/19 10:47,
38.107.191.111:LOG IN
|
| ©2010 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? Please DO link to this page! Digg it! <A HREF="http://www.piclist.com/techref/language/ccpp/cref/EXAMPLES/sprintf.c"> language ccpp cref EXAMPLES sprintf</A> |
| Did you find what you needed? |
Watch, recieve and send I2C via serial port. 100Kb/s. Also 5 TTL out & 8 in. $15 chip $30 w/ PCB $40 kit $50 A&T |
Robotics nuts!Check out http://www.verinet.com/~dlc/ email: dlc@verinet.com... This guy ROCKS! He has made (and sells but also releases code, docs, etc...) for a number of cool little robotic modules including whiskers, IR proximity detect and remote control, Sonar proximity detect, PWM, Servo, compass. Most of these use the little PIC 12C508 controller which costs basically nothing and is soooo tiny.The 4 servos, 2400 baud serial servo controller is a wonder of magic and he sells the programmed chip for $8. Wow! |
.