Dont try use objects from MFC without building an MFC project (CString)....just adding afx.h will not work as you need the rest of the MFC framework
Also drop void main...use int main and return a value
If you want a string, look no further than the std C++ library's string object...that will give you the substr() function that you crave...
void sub_str(string str)
cout << endl << str.substr(2,3) << endl;
cout << "Enter value : ";
cin >> str;