I am trying to learn C to develop my skills in programming and I am trying to make an algorithm which could change the uppercase letter to lowercase letter and lowercase letter to uppercase letter.In simple algorithm I have written this code but an error occurs on it,my question is the compiler says "operand types are incompatible".What does it mean?I called my length as a pointer function to store a memory in the address to enter the console random characters.Error occurs in i is smaller than length in for loop part.I am looking forward to learn new things from your replys."int" and "int(*)char *s") it says
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
int length(char *s)
{
int i = 0;
int counter = 0;
while (s[i] != NULL)
{
i++;
counter++;
}
return counter;
}
void upperlower(char *s)
{
int i;
for (i = 0; i<length; i++)
{
if (s[i] >= 65 && s[i] <= 90)
s[i] += 32;
else if (s[i] >= 97 && s[i] <= 122)
s[i] -= 32;
}
}
int main()
{
printf("Please write down the character string: ");
scanf("%s", upperlower);
printf("The character string is %s", upperlower);
getch();
return 0;
}