파일에서 문자열 (이 경우 이름)을 검색하는 프로그램을 작업 중입니다. 프로그램이 대소 문자를 구분하지 못하도록하고 싶었지만 strcmp가 있습니다. 나는 파일과 사용자 입력을 소문자로 변환하려고 생각하고 있었다. 그러나 그것은 비효율적 일 것입니다. 이것을 극복 할 수있는 다른 제안이 있습니까?
이것은 단지strcmpi()를 사용하지 않고 strcmp() 대소 문자를 구분하지 않음 (C++)
cout << "\n Enter the Guests name: ";
cin.getline(look_4_person, 256); //name that is being looked up
cout << "\n Searching... \n";
while(!name_file.eof())
{
++place;
name_file.getline(person,255);
if(strcmpi (person,look_4_person)==0)
{
found=place;
}
}
cout << "\n" << look_4_person << " is number " << found <<
" on the list \n";
이것은 끔찍한 스타일이며 'while (! name_file.eof())'은 버그입니다. 좋은 책에서 현대 C++을 읽어야합니다. –
@BaummitAugen 현재 Big C++ (2nd Edition)를 사용 중입니다. 의견이 있습니까? – Pouya
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list –