For example, such a problem: Enter a positive integer and convert it to a positive integer. It can be implemented with sprintf and snprint. code show as below:
#include <stdio.h>
#include <string.h>
int a=0;
char buffer[8];
int main() {
do {
printf("input an unsigned int:");
scanf("%u", &a);
} while(a<0);
snprintf(buffer, sizeof(buffer)+1, "%d", a);
printf("length of buffer:%d, value is:%s\n ", strlen(buffer), buffer);
return 0;
}