Explain a file operation in C with an example.
Answer / Shalini Gupta
"A common file operation in C is reading a file. Here's an example using the 'fopen', 'fread', and 'fclose' functions:n- Open the file: `FILE *fp = fopen("example.txt", "r")`n- Read data from the file: `int ch; while((ch = fgetc(fp)) != EOF) printf("%c", ch);`n- Close the file: `fclose(fp);`
| Is This Answer Correct ? | 0 Yes | 0 No |
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }
What is the use of typedef in structure in c?
What will be the result of the following program? main() { char p[]="String"; int x=0; if(p=="String") { printf("Pass 1"); if(p[sizeof(p)-2]=='g') printf("Pass 2"); else printf("Fail 2"); } else { printf("Fail 1"); if(p[sizeof(p)-2]=='g') printf("Pass 2"); else printf("Fail 2"); } } a) Pass 1, Pass 2 b) Fail 1, Fail 2 c) Pass 1, Fail 2 d) Fail 1, Pass 2 e) syntax error during compilation
What is wrong with this statement? Myname = 'robin';
Explain how do you search data in a data file using random access method?
In c programming language, how many parameters can be passed to a function ?
What is meant by operator precedence?
This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory
Explain pointer. What are function pointers in C?
how to generate the length of a string without using len funtion?
Describe the header file and its usage in c programming?
Explain what is output redirection?