I need to print out a string along with a integer in a signal handler function. I was told that write is signal safe. So far I have tried to print out an integer with write but it gives off weird symbols. Write worked for a char array of characters but doesn't work for integers. Any advice would be much appreciated. Below is my code which gave off the error.
#include<stdio.h>
#include<wait.h>
#include<signal.h>
#include<unistd.h>
int main()
{
int x[] = {100000};
write(1, x, sizeof(x));
return 0;
}