0

Error: In function ‘int main()’: holes.cpp:14:11: error: ‘strlwr’ was not declared in this scope strlwr(s);

Here's my code:

#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
int main()
{
    int t,c[40]={0};
    char s[100];
    int i;
    cin>>t;
    for(i=0;i<t;i++)
    {
        cin>>s;
        strlwr(s);
        for(int j=0;j<strlen(s);j++)
        {
            if(s[j]=='q'||s[j]=='r'||s[j]=='o'||s[j]=='p'||s[j]=='a'||s[j]=='d')
                c[i]++;
            else if(s[j]=='b')
                c[i]+=2;
        }
    }
    for(i=0;i<t;i++)
        cout<<c[i]<<endl;
    return 0;
}           

I tried doing using std::strlwr, still it does not work. I saw a solution elsewhere to include cstring instead of string, still it does not work. Help please!

Anton Savin
  • 40,838
  • 8
  • 54
  • 90
  • Uh? Because there is no such function in glibc (gcc's typical standard library) perhaps? Apparently, Microsoft's compiler DOES have this. Maybe you want to switch OS - or have a look at this: http://stackoverflow.com/questions/2661766/c-convert-a-mixed-case-string-to-all-lower-case – Mats Petersson Jun 21 '15 at 09:12
  • [Although given that you look at each character at a time, maybe something like `char cc = tolower(s[j])` and then using `cc` instead of `s[j]` in the conditionals would work as well] – Mats Petersson Jun 21 '15 at 09:16

0 Answers0