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...
Code:
#include <string>
#include <iostream>
using std::string;
using std::cout;
using std::endl;
using std::cin;
void sub_str(string str)
{
cout << endl << str.substr(2,3) << endl;
};
int main(){
string str;
cout << "Enter value : ";
cin >> str;
sub_str(str);
return 0;
}