What is the problem with the following code segment?
while ((fgets(receiving array,50,file_ptr)) != EOF)
;
Answer / susie
Answer : & Explanation:
fgets returns a pointer. So the correct end of file check is
checking for != NULL.
| Is This Answer Correct ? | 6 Yes | 1 No |
struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); } a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above
x=2 y=3 z=2 x++ + y++; printf("%d%d" x,y);
main() { int i=-1; -i; printf("i = %d, -i = %d \n",i,-i); }
There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong? void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts(stud.name); } }
main() { if ((1||0) && (0||1)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above
main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }
how to print 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 using any loop(for or while) only once(only 1 loop) and maximum 2 variables using C.
19 Answers Cap Gemini, Infosys,
Finding a number multiplication of 8 with out using arithmetic operator
write the function. if all the character in string B appear in string A, return true, otherwise return false.
find A^B using Recursive function
main() { char *p; p="Hello"; printf("%c\n",*&*p); }
void main() { char a[]="12345\0"; int i=strlen(a); printf("here in 3 %d\n",++i); }