jeudi 9 juillet 2020

error: no matching function for call to 'toupper(char*)'| [closed]

Why is the "toupper" function not working in the following code:

    #include <iostream>
    #include "cctype"
    using namespace std;

    int main()
    {
        string any;
        cout<<"Enter the string:";
        cin>>any;
        getline(cin,any);
        for (auto &c : any)
            c = toupper(c);
        cout<<any;
        return 0;
     }

But it is working in this one:

    string s("Hello World!!!"); //This code is from C++ primer
    for (auto &c : s)  
        c = toupper(c); 
    cout << s << endl;

I tried referring to the other solutions about the overloading function etc (here:std::transform() and toupper(), no matching function) Edit: It's solved now!It's not giving any error now(the first code) Sorry for inconvenience!

Aucun commentaire:

Enregistrer un commentaire