Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- typedef struct time {
- int second;
- int minute;
- int hour;
- }TIME;
- TIME *t= (TIME*)malloc(sizeof(TIME));
- int main()
- {
- /*input.txt 생성*/
- int i,size;
- FILE *fp = fopen("input.txt", "rt");
- fscanf(fp, "%d", &size);
- for (i = 0; i < size; i++) {
- fscanf(fp, "%d %d %d", &t[i].hour, &t[i].minute, &t[i].hour);
- }
- srand(time(NULL));
- fclose(fp);
- /*input.txt 에서 읽어 구조체에 저장*/
- fp = fopen("output.bin", "wb");
- fwrite(&size, sizeof(int), 1, fp);
- for (i = 0; i < size; i++) {
- fwrite(&t[i].hour, sizeof(int), 1, fp);
- fwrite(&t[i].minute, sizeof(int), 1, fp);
- fwrite(&t[i].second, sizeof(int), 1, fp);
- }
- /*구조체에서 읽어 bin파일에 저장*/
- fclose(fp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement