1 #include <stdio.h>
2 #include <stdlib.h>
3
main()4 int main()
5 {
6 char test[100] = {0};
7 FILE *fp;
8 char str[60];
9
10 /* opening file for writing */
11 fp = fopen("file.txt" , "w");
12 if(fp == NULL)
13 {
14 perror("Error opening file");
15 return(-1);
16 }
17 fprintf(fp, "testing %s", "abcdef");
18 fclose(fp);
19
20 fgets(test, 5, stdin);
21 if (!strcmp(test, "xyz\n")) {
22 fwrite("good1\n", 1, 6, stdout);
23 }
24 else if (!strcmp(test, "wxyz")) {
25 fwrite("good2\n", 1, 6, stderr);
26 }
27 if (!strcmp(test, "a\nb")) {
28 puts("not possible");
29 }
30
31 return 0;
32 }
33
34