Attempting to detect a string in c++ -
i have code assignment here.
stringstream fnamestream(fname); stringstream lnamestream(lname); if (fnamestream >> word) { fnamestream >> names[count]; count++; } else { fnamestream << "john"; fnamestream >> names[count]; count++; }
the error no values @ when check array later. i'm not sure issue is. when entered in values before without if loop able values, when way nothing. apologies if incoherent or not clear (just let me know) i'm quite hungover.
does work?
bool isword(std::string s) { (int = 0; < s.length; ++i) { if (!::isalpha(s[i])) return false; } return true; } int main() { while (fnamestream >> word) { if (isword(word)) { names[count++] = word; } else { // placeholder } } }
Comments
Post a Comment