What is the problem with the following code segment?

while ((fgets(receiving array,50,file_ptr)) != EOF)

;



What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr))..

Answer / susie

Answer : & Explanation:

fgets returns a pointer. So the correct end of file check is
checking for != NULL.

Is This Answer Correct ?    5 Yes 1 No

Post New Answer

More C Code Interview Questions

Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

9 Answers   Microsoft,


how to delete an element in an array

2 Answers   IBM,


union u { struct st { int i : 4; int j : 4; int k : 4; int l; }st; int i; }u; main() { u.i = 100; printf("%d, %d, %d",u.i, u.st.i, u.st.l); } a. 4, 4, 0 b. 0, 0, 0 c. 100, 4, 0 d. 40, 4, 0

1 Answers   HCL,


#include<conio.h> main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }

1 Answers  


Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };

1 Answers  






Is the following statement a declaration/definition. Find what does it mean? int (*x)[10];

1 Answers  


void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }

1 Answers  


What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }

1 Answers  


main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

2 Answers  


PROG. TO PRODUCE 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

1 Answers  


void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above

1 Answers   HCL,


main() { int a[10]; printf("%d",*a+1-*a+3); }

1 Answers  


Categories