Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- int _tmain(int argc, _TCHAR* argv[])
- {
- int N=10,i=0,*mas;
- FILE *f;
- fopen_s(&f,"massiv.txt","rt");
- if (f==NULL) {
- printf("Error in file!");
- return -1;
- }
- mas = (int *) malloc(sizeof(int)*N);
- while (!feof(f))
- {
- int val=0;
- fscanf_s(f,"%d",&mas[i++]);
- if (i==N)
- {
- N+=5;
- mas=(int *) realloc(mas, sizeof(int)*N);
- }
- }
- for (int k=0; k<i-1; k++)
- printf ("%d\t", mas[k]);
- fclose(f);
- printf("It's OK!\n");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement