c -signal problem

+1 popescu alex · May 12, 2015
hi guys i have a question  
can you tell my way  the compiler don't activate the signal and give  error when i introduct this code :
#include <signal.h>
#include <stdio.h>
static void catch_function(int signal) {
puts("Interactive attention signal caught.");
}
int main(void) {
if (signal(SIGINT, catch_function) == SIG_ERR) {
fputs("An error occurred while setting a signal handler.\n", stderr);
return EXIT_FAILURE;
}
puts("Raising the interactive attention signal.");
if (raise(SIGINT) != 0) {
fputs("Error raising the signal.\n", stderr);
return EXIT_FAILURE;
}
puts("Exiting.");
return 0;
}

and i will appreciate some suggestions 
thanks

Post a Reply

Replies

Oldest  Newest  Rating
0 popescu alex · August 25, 2015
hey guys i have a problem with rename function can anyone help me .here is the code :

#include <stdio.h>

int main ()
{
int ret;
char oldname[] = "file.txt";
char newname[] = "newfile.txt";

ret = rename(oldname, newname);

if(ret == 0)
{
printf("File renamed successfully");
}
else
{
printf("Error: unable to rename the file");
}

return(0);
}

thanks 
0 Jon Z. · August 26, 2015
where is your rename function?
  • 1

C

107,269 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator