Hi, --- In [email protected], ravisankar kakumanu <[EMAIL PROTECTED]> wrote: > > Hi Friends, > > Can you plzz tell me whats wrong with this code. > > #include <stdio.h> > #include <math.h> > > main () { > > FILE *fp; > > fp = fopen("file.txt", "r"); > if(fp==NULL){ > printf("\n Cannot open file.txt file.\n"); > exit(1); > } > else { > printf("\n file.txt File is Opened.\n"); > > } > } > > The file.txt is not having any value but surprisingly iam getting the following message when i run the above code What do you mean by that "file.txt is not having any value", the file does not exit or is empty?
> > file.txt File is Opened. > > Can you please tell me why iam getting this? What do you expect here? If the file exists and user is allowed to access it then the code sould fall into else loop and print "file.txt File is opened". If this is not clear then maybe you can elaborate a bit more on your problem! ~Saurabh
