There is a code that reads a file and writes out all the declared variables along with the types.
int _tmain(int argc, _TCHAR* argv[]) { vector <string> v(0); v.push_back("int"); v.push_back("char"); v.push_back("string"); v.push_back("mas"); v.push_back("bool"); string b; string k; ifstream file("Studying.cpp"); while (getline(file, b)) { for (int i = 0; i < b.length(); i++) { for (int j = 0; j < v.size(); j++) { if ((b.find(v[j]) != string::npos) && (b.find(";") != string::npos)) { int t = b.find(v[j]); int h = b.find(";"); k = b.substr(t, h); cout << k << endl; b.erase(t, h + 1); } else b.erase(); } } } file.close(); system("pause"); The problem lies in the second for loop. It checks only the first element of the vector, that is, v [0], and omits the rest. If v [j] is replaced by v [0] .. v [4], then each of the types is excellent. How to make everything output if such a cycle does not work?
i? Just do the same thing many times? :)iis not used in the body of the cycle ... - Harry