Program:
#include <stdio.h>
#include <sys/inotify.h>
int main()
{
    int fd = inotify_init();
    int wd1 = inotify_add_watch(fd, "/home/guest/a", IN_MODIFY);
    struct inotify_event *event = (struct inotify_event*) malloc(sizeof(struct inotify_event));
    read(fd, event, 1000);
    if (event->mask & IN_MODIFY) {
        printf("File '%s' is modified\n", event->name);
    }
}
Output:
$ ./a.out 
File '' is modified
$
I expected that the above program will notify with the filename if file a is modified. But it notify without filename. So, how to get the filename if the file is modified using inotify.
 
     
    