Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <conio.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <fstream>
- #include <time.h>
- #define max_size 255
- using namespace std;
- int I, N = 0;
- int *main_massive;
- char buf[max_size];
- int *create_massive(int *main_massive );
- int main()
- {
- ifstream file;
- file.open("1.txt",ios::in);
- if (!file)
- {
- cout << "cannot open the file";
- _getch();
- return 1;
- }
- file.getline(buf,max_size);
- cout << buf<<"\n\n";
- main_massive = create_massive(main_massive);
- for(I = 0;I<N;I++)
- cout << main_massive[I];
- file.close();
- _getch();
- return 0;
- }
- int *create_massive (int *main_massive)
- {
- int date_position = 0;
- for (I = 0;I < strlen(buf);I++)
- if (isdigit(buf[I]))
- N++;
- main_massive = new int[N];
- for (I = 0;I < strlen(buf);I++)
- if (isdigit(buf[I]))
- {
- main_massive[date_position] = atoi (&buf[I]);
- date_position++;
- }
- return main_massive;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement