Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <cstring>
- using namespace std;
- int main()
- {
- string str;
- int *statistic = new int [0];
- char slovo[15];
- for(int i = 0; i<15; i++){
- slovo[i] = ' ';
- }
- int count_word = 0;
- char** words = new char* [0];
- for (int i = 0; i<count_word; i++){
- words[i] = new char[15];
- }
- ifstream text("text.txt");
- while (getline(text, str, ' ')){
- cout<<endl<<endl;
- for (int i = 0; i<str.size(); i++){
- slovo[i] = str[i];
- }
- cout<<"generate new_words "<<count_word<<endl;
- char** new_words = new char*[count_word];
- for (int i = 0; i<count_word; i++){
- new_words[i] = new char[15];
- }
- for (int i = 0; i<count_word; i++){
- for (int j = 0; j<15; j++){
- new_words[i][j] = words[i][j];
- }
- }
- cout<<"delete words "<<count_word<<endl;
- for (int i = 0; i<count_word; i++){
- delete words[i];
- }
- delete [] words;
- count_word += 1;
- cout<<"generate words "<<count_word<<endl;
- char** words = new char* [count_word];
- for (int i = 0; i<count_word; i++){
- words[i] = new char[15];
- }
- for (int i = 0; i<count_word-1; i++){
- for (int j = 0; j<15; j++){
- words[i][j] = new_words[i][j];
- }
- }
- cout<<"delete new_words "<<count_word-1<<endl;
- for (int i = 0; i<count_word-1; i++){
- delete new_words[i];
- }
- delete [] new_words;
- for (int i = 0; i<15; i++){
- words[count_word-1][i] = slovo[i];
- }
- //вывод массива в цикле
- for (int i = 0; i<count_word; i++){
- for (int j = 0; j<15; j++){
- cout<<words[i][j];
- }
- cout<<endl;
- }
- cout<<endl<<endl;
- }
- text.close();
- /* for (int i = 0; i<1; i++){
- for (int j = 0; j<15; j++){
- cout<<words[i][j];
- }
- cout<<endl;
- }*/
- return 0;
- }
Add Comment
Please, Sign In to add comment