C Programme এ কোনো file থেকে কিভাবে information নিব?
কোনো একটি file এ এ রুপ information আছে :
| Name | Age |
| Rahim | 22 |
| Karim | 19 |
| Asif | 24 |
| Saif | 28 |
বা,
Rahim = 22;
Karim = 19;
Asif = 24;
Saif = 28;
* কোনো একটি programme এ কিভাবে ওই file এর information ব্যবহার করতে পারবো।
(Programme টি লিখে বোঝাবেন please)
2926 views
1 Answers
- // file থেকে read
-
-
#include
-
#include
- int main()
- {
- char ch, file_name[25];
- FILE *fp;
- printf("Enter name of a file you wish to see\n");
- gets(file_name);
- fp = fopen(file_name, "r"); // read mode
- if (fp == NULL)
- {
- perror("Error while opening the file.\n");
- exit(EXIT_FAILURE);
- }
- printf("The contents of %s file are:\n",file_name);
- while((ch = fgetc(fp)) != EOF)
- printf("%c", ch);
- fclose(fp);
- return 0;
- }
2926 views
Answered
Related Questions
Next steps
- Find a doctor for in-person or online consultation
- Browse medical tests patients often ask about
- Check medicine information (uses, dosage, brands in Bangladesh)
- More health Q&A on Bissoy