Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- struct str_in{
- char str[100];
- int num;
- };
- int main()
- {
- struct str_in str_in_ar[3];
- int i;
- FILE *fp;
- for(i=0;i<3;i++)
- {
- printf("Enter a string(100 character limit): ");
- fflush(stdin);
- gets(str_in_ar[i].str);
- printf("Enter a number: ");
- fflush(stdin);
- scanf("%d",&str_in_ar[i].num);
- }
- printf("Writing it to file.....");
- fp = fopen("str_55.txt","a");
- if(fp)
- {
- for(i=0;i<3;i++)
- {
- fprintf(fp,"%s : %d\n",str_in_ar[i].str,str_in_ar[i].num);
- }
- fclose(fp);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment