In C++, you use string types to read in strings. A string type automatically adjusts it's size to handle whatever length string you need to read into it:
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str = "hello";
cout<<str<<endl;
str = "hello world";
cout<<str<<endl;
return 0;
}
A string type can be treated like an array, with the first character at index 0 and the next character at index 1, etc. You can use the string function substr() to extract portions of the string you are interested in:
Code:
string str = "06John";
cout<<str.substr(0,2)<<endl;
cout<<str.substr(2)<<endl;