Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication5.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- FILE *f;
- struct tochka
- {
- int x, y;
- } A[10];
- int _tmain(int argc, _TCHAR* argv[])
- {
- int i;
- int r=fopen_s(&f, "1.txt", "wt");
- if(r!=0)
- {
- printf("Error! %d \n", r);
- return -1;
- }
- for(i=0; i<10; i++)
- {
- A[i].x=2*i+1;
- A[i].y=3*i;
- }
- for(i=0; i<10; i++)
- {
- fprintf_s(f, "(%d,%d)\n", A[i].x, A[i].y);
- }
- fclose(f);
- for(i=0; i<10; i++)
- {
- A[i].x=0;
- A[i].y=0;
- }
- r=fopen_s(&f, "1.txt", "rt");
- if(r!=0)
- {
- printf("Error! %d \n", r);
- return -1;
- }
- i=0;
- while(!feof(f))
- {
- fscanf_s(f, "(%d,%d)\n", &A[i].x, &A[i].y);
- printf_s("(%d,%d)\n", A[i].x, A[i].y);
- if(i++==10)
- break;
- }
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement