#include<stdio.h>
int main ()
{
FILE *fp;
fp = fopen("3GWC.txt","r");
char sentence[20];
int count=0;
while (feof(fp)!=1)
{
fgets(sentence, 20, fp);
count++;
}
printf("Value of Count:%d\n",count);
}
This code gives me a segmentation fault when run using the nvidia c compiler. I ran the same code using gcc (ofcourse after changing the file extention to .c) and it ran perfectly. The file I used 3GWC.pdb is attached with this post.
I also ran valgrind to check memory errors. Valgrind pointed out that there is an error with the fgets statement. Kindly try this code on your nvccompiler and see whether it runs. Do share the output with me.
Please save this code as a .cu file and then run it on your Nvidia C Compiler and not Gcc. Is it not throwing up errors?? I can run this code without errors in gcc but not on nvcc.