sprintf() is for string, while fprintf() is for file.
#include <stdio.h>
int main(void)
{
int a = -100;
FILE *fp;
unsigned char str[10];
sprintf(str, "%d", a); // str is string ptr.
printf("str: %s\n", str);
fp = fopen("/tmp/fprintf.txt", "w+");
fprintf(fp, "%s\n", str); // fp is a file ptr.
fclose(fp);
}