I want to write a C function that will print 1 to N one per each line on the stdout where N is a int parameter to the function. The function should not use while, for, do-while
#include "stdio.h"
#include "stdlib.h"
#include "signal.h"
int g_num;
int iterator;
void signal_print()
{
if(iterator>g_num-1)
exit(0);
printf("%d\n",++iterator);
}
void myprintf(int n)
{
g_num=n;
int *p=NULL;
int x= *(p); // the instruction is reexecuted after handling the signal
}
int main()
{
signal(SIGSEGV,signal_print);
int n;
scanf("%d",&n);
myprintf(n);
return 0;
}