So i have a txt file with this in it:
Code:
1. Assamese/Asomiya
2. Bengali/Bangla
3. Bodo
4. Dogri
5. Gujarati
6. Hindi
7. Kannada
8. Kashmiri
9. Konkani
10. Maithili
11. Malayalam
12. Manipuri
13. Marathi
14. Nepali
15. Oriya
16. Punjabi
17. Sanskrit
18. Santhali
19. Sindhi
20. Tamil
21. Telugu
22. Urdu
and i would like to copy those which begins with 'H' or 'S' to an out.txt file with the numbers. I have the solution,but i would like to ask why the lang contains only the names without numbers?and the num contains only numbers... when i used the same scanf, with my logic it makes non sense,because it should copy the same information but obviously not. so the question is,why?
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{ int endoffile=1;
FILE *fp;
FILE *out;
char lang[30];
char num[30];
out=fopen("c:\\out.txt","w");
fp=fopen("c:\\bhaarat.txt", "r+a");
while(endoffile==1)
{
endoffile=fscanf(fp,"%s",&num);
endoffile=fscanf(fp,"%s",&lang);
if(lang[0]=='S' || lang[0]=='H')
fprintf(out,"%s %s\n",num,lang);
}
fprintf(fp,"23. English");
fclose(out);
fclose(fp);
return 0;
}