D
D
Dauren S2016-10-14 18:51:30
C++ / C#
Dauren S, 2016-10-14 18:51:30

c++ string split into array?

int theory() {
  string s;
  ifstream f;
  f.open("cppdauren.txt", ios::in);
  if (!f)
  {
    cout << "Ошибка отрытия теоретического материала";
  }
  else{
    char ch;
    while (getline(f, s)){
      cout << s << endl;
      
    };
    
    /*
    for (s; getline(f, s);)
    {
      cout << s << endl;
    }*/
  }
  system("pause");
  return 0;

}
How to divide a c++ string into an array so that each element has n-th number of characters?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2016-10-14
@petermzg

In C++, a string is an array.
If you do not have a multibyte, then simply

char* str = "text";
char* strpart = str + 2;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question