I know that strchr, searches for the first occurences of a char in a string... I just wanted know if I can use this code to count characters in a string as example.
String: An apple a day keeps the doctor away
Char to search: a
Result: Found a 6 times in String.
1. I have figured out something like this.
But this code didn't work... so I just need a bugfix in this code could you help me out a little bit ???
char *ptr, c = 'i';
strcpy(string, "This is a string");
ptr = strchr(string, c);
ptr = strchr(string, NULL);
printf("Char %c, found %d times in string", c, i);
printf("Char was not found in string");
2. How do I get this code to find also the Uppercase and the Lowercase 'A' in this code ?
Thanks in advance