किसी कारण से, मेरे टू चेक चर का मूल्य मिटा दिया जा रहा है और मुझे नहीं पता कि क्यों। कोई सुझाव?मेरी स्ट्रिंग का मूल्य क्यों खो रहा है?
bool
check(string toCheck){
printf("toCheck: %s\n", toCheck.c_str());
ifstream list;
list.open("list.txt");
string temp;
while(list){
getline(list,temp);
printf("toCheck: '%s' temp: '%s'\n",toCheck.c_str(), temp.c_str());
if(temp == toCheck){
printf("Username exists\n");
return false;
}
}
printf("returning true\n");
return true;
}
यहाँ यह क्या पारित किया जा रहा है: TestTrevor
और यहाँ उत्पादन है:
toCheck: TestTrevor toCheck: '' temp: 'Trevor' toCheck: '' temp: '' Username exists
list.txt की सामग्री क्या हैं? – JohnFx
आपको "list.txt" के माध्यम से कुछ अंधेरे जादू को चैनल करना होगा। – ScarletAmaranth
list.txt को हटा रहा है, और बस temp के लिए कुछ dummyvalues में subbing, आपके कोड मेरे MacbookPro पर अपेक्षित काम करता है। – Alan