Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct Info
- {
- char name[10];
- int number;
- };
- int main()
- {
- struct Info in;
- FILE *fp;
- if((fp = fopen("input.txt", "wb")) == NULL)
- {
- printf("Error opening file.\n");
- exit(1);
- }
- scanf("%d", &in.number);
- getchar();
- gets(in.name);
- if(fwrite(&in, sizeof in, 1, fp) != 1)
- {
- printf("Error writing to file\n");
- exit(2);
- }
- fclose(fp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement