C++ toLowerCase Function won't work - Access violation
- by misaizdaleka
Hi,
I have a simple function which takes an array of characters as an argument, and converts all the characters to lower case. However, I get a weird access violation error. Here's the code:
void toLower(char *rec)
{
int i=0;
while (rec[i]!='\0')
{
if (rec[i]>='A' && rec[i]<='Z')
rec[i]='a'+rec[i]-'A'; //this is where I get an error - assigning the
//the value to rec[i] is the problem
i++;
}
}
Can you tell me what's my mistake?
Thanks