I m trying to execute the below snippet but ending in Seg fault.
gdb points to line 16 in "while" loop. If I comment out the "stat" at line 12, code runs fine. Does "stat" locks the file that I m trying to access later ?
Can anyone help reg this ?

Code:
  1 #include<stdio.h>
  2 #include<stdlib.h>
  3 #include<sys/types.h>
  4 #include <sys/stat.h>
  5
  6 main()
  7 {
  8   FILE *fp;
  9   char *s;
 10   char f[] = "/home/ramchan/bin/C/ram";
 11   struct stat buffer ;
 12   int k = stat( f, &buffer) ;
 13       printf("\nk is %d",k);
 14
 15     fp =  fopen("ram","r");
 16     while(fgets(s,10,fp)!=NULL)
 17     {
 18       printf("\n here");
 19       printf("%s",s);
 20     }
 21   }