Advertisement
andruhovski

prog-0302c

Oct 4th, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. // ConsoleApplication5.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6. FILE *f;
  7. struct tochka
  8. {
  9.     int x, y;
  10. } A[10];
  11.  
  12. int _tmain(int argc, _TCHAR* argv[])
  13. {
  14.     int i;
  15.     int r=fopen_s(&f, "1.txt", "wt");
  16.  
  17.     if(r!=0)
  18.     {
  19.         printf("Error! %d \n", r);
  20.         return -1;
  21.     }
  22.  
  23.     for(i=0; i<10; i++)
  24.     {
  25.         A[i].x=2*i+1;
  26.         A[i].y=3*i;
  27.  
  28.     }
  29.     for(i=0; i<10; i++)
  30.     {
  31.         fprintf_s(f, "(%d,%d)\n", A[i].x, A[i].y);
  32.     }
  33.     fclose(f);
  34.  
  35.     for(i=0; i<10; i++)
  36.     {
  37.         A[i].x=0;
  38.         A[i].y=0;
  39.  
  40.     }
  41.  
  42.     r=fopen_s(&f, "1.txt", "rt");
  43.  
  44.     if(r!=0)
  45.     {
  46.         printf("Error! %d \n", r);
  47.         return -1;
  48.     }
  49.     i=0;
  50.     while(!feof(f))
  51.     {
  52.         fscanf_s(f, "(%d,%d)\n", &A[i].x, &A[i].y);
  53.         printf_s("(%d,%d)\n", A[i].x, A[i].y);
  54.         if(i++==10)
  55.             break;
  56.     }
  57.     fclose(f);
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement