Can someone help me
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
int main(int argc, char **argv)
{
int i;
struct stat *buf;
for (i = 1; i < argc; i++)
{
if (stat(*(argv + i), buf) == -1)
{
fprintf(stderr, "%s: cannot access %s\n", *(argv), *(argv + i));
continue;
}
printf("Hello\n");
}
}
Hi
Can someone help me whats wrong with my code on line 14 if(stat() == -1)? my code compiles fine on gcc, but when i run my code, i get segmentation fault (core dumped).
my code works fine when i use char *argv[], but not with doube pointer.
Thanks
Regards
Mani
|