Question: I'm constantly receiving the same error when i compile my program Here's the error: C6.1.c:72:48: warning: format specifies type 'int' but the argument has type

I'm constantly receiving the same error when i compile my program

Here's the error:

C6.1.c:72:48: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]

printf("There are %d total characters. ", strlen(str));

Here's my program:

#include

#include

#include

bool isVowel(char);

int countUC(char *);

int countLC(char *);

int countOthers(char *);

int countVowels(char *);

bool isVowel(char ch) {

return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||

ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U';

}

int countUC(char *str) {

int count = 0, i = 0;

char ch;

while((ch = str[i++])) {

if(ch >= 'A' && ch <= 'Z') {

++count;

}

}

return count;

}

int countLC(char *str) {

int count = 0, i = 0;

char ch;

while((ch = str[i++])) {

if(ch >= 'a' && ch <= 'z') {

++count;

}

}

return count;

}

int countOthers(char *str) {

int count = 0, i = 0;

char ch;

while((ch = str[i++])) {

if(!((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))) {

++count;

}

}

return count;

}

int countVowels(char *str) {

char *s = str;

int vowel = 0;

while (*s != '\0') {

if (isVowel(*s)) {

vowel++;

}

s++;

}

return vowel;

}

int main() {

char str[100];

int i;

int vowels = 0;

int UC;

int LC;

int Others;

int c;

printf("Enter a sentence: ");

gets(str);

LC = countLC(str);

UC = countUC(str);

Others = countOthers(str);

printf("There are %d total characters. ", strlen(str));

printf("There are %d vowels. ", countVowels(str));

printf("There are %d UPPERCASE letters. ", UC);

printf("There are %d lowercase letters. ", LC);

printf("There are %d other characters. ", Others);

return (0);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!