konvertieren von Zeichenfolgen in Kleinbuchstaben mit tolower () - Funktion in c++

Ich habe eine text-Datei namens aisha

This is a new file I did it for mediu.
Its about Removing stopwords fRom the file
and apply casefolding to it
I Tried doing that many Times
and finally now I could do

und ich habe einen code zu Lesen, dass die text-Datei und speichern Sie es in ein array umwandeln und dann einige Zeichen zu lowrcase
aber was ich will ist zu machen, die die codes liest die Datei als ein string kein char

char myArray[200];

werden

`string myArray[200];`

Ich glaube, ich kann es mit der Funktion tolower() - und einen string, std
statt dass der lange code, den ich verwendet
aber ich weiß nicht, wie mein code, ein code, der verwendet, dass die Funktionen

mein code ist

#include <iostream>
#include <string>
#include <fstream>
#include<ctype.h>
int main()
{
    using namespace std;

    ifstream file("aisha.txt");
    if(file.is_open())
    {
        file >> std::noskipws;
         char myArray[200];

        for(int i = 0; i < 200; ++i)
        {


            cout<<"i";
            if (myArray[i]=='A')
            cout<<"a";
            if (myArray[i]=='T')
            cout<<"t";
            if (myArray[i]=='R')
            cout<<"r";
            else 
            if (myArray[i]!='I' && myArray[i]!='T' && myArray[i]!='R'&& myArray[i]!='A')
            cout<<myArray[i];
            }
         file.close();

        }

system("PAUSE");
return 0;
}

Sah ich, dass die Lösung in diesem Ort
aber ich konnte es anwenden, meinen code

#include <boost/algorithm/string.hpp>    

std::string str = "wHatEver";
boost::to_lower(str);

Otherwise, you may use std::transform:

std::string str = "wHatEver";
std::transform(str.begin(), str.end(), str.begin(), ::tolower);

InformationsquelleAutor Aisha Ahmed Ahmed | 2013-12-01

Schreibe einen Kommentar