mercredi 26 février 2020

i.m trying to split string by whitespace using c++, where the data from database

i have tried this, the compilation's result is no error, but the result of running is not suitable

therefore i'm freaking desperate to solve this problem, i have been trying since 2 weeks ago but got nothing

using namespace std;
int main()
{
int j, count = 0;
char del[] = ".,/;:";
string hadis;
MYSQL* conn;
MYSQL_ROW row;
MYSQL_RES* res;
conn = mysql_init(0);
conn = mysql_real_connect(conn, "192.168.43.205", "ibrahim", "hadis", "hadis", 0, NULL, 0);
if(conn)
{
    int qstate = mysql_query(conn, "SELECT Isi_Indonesia FROM malik");
    if(!qstate)
    {
        res = mysql_store_result(conn);
        while(row = mysql_fetch_row(res))
        {
            hadis = row[0];
            for(unsigned int i=0;i<strlen(del);++i)
            {
                hadis.erase (remove(hadis.begin(), hadis.end(), del[i]), hadis.end());
                }
            for (j=0; hadis[j]; j++)
            {
                if (hadis[j] == ' ')
                count++;
                cout<< "-";
            }
            cout<<hadis[j];
        }
    }
}
return 0;

}

Aucun commentaire:

Enregistrer un commentaire