#include <stdio.h>
cant figure it out, im trying to count all digits
please help with this bugs
int main()
{
int iochar, numdigits=0, numlower=0, numupper=0, numwhites=0;
printf("Please enter a phrase:\n\n");
while((iochar=getchar())!=EOF)
{
if ((iochar='\o ')||(iochar='\t')||(iochar='\n'))
{
numwhites++;
putchar(iochar);
}
else
if((iochar>='0')&&(iochar<='9'))
{
numdigits++;
putchar(iochar);
}
else
if(('a'<=iochar)&&(iochar<='z'))
{
numlower++;
putchar(iochar-32);
}
else
if(('A'<=iochar)&&(iochar<='Z'))
{
numupper++;
putchar(iochar);
}
else
putchar(iochar);
}
printf("%d white characters, %d digits, ",numwhites,numdigits);
printf("%d lowercase have been converted to ",numlower);
printf("uppercase and %d uppercase.\n",numupper);
printf("\n\n");
return 0;
}
alex1050
-4
Newbie Poster
Recommended Answers
Jump to PostInteresting post. You might want to work on your formatting, though. It's inconsistent.
Jump to PostHello alex1050,
In the line 15 it looks like '\o'(letter 'o') it should have been '\0'(zero).
Jump to PostAnd also it should be == in the if-else (line 15) block as you are comparing the iochar with '\0' etc,.
if ((iochar=='\0')||(iochar=='\t')||(iochar=='\n'))
All 12 Replies
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Arbus
25
Practically a Master Poster
alex1050
-4
Newbie Poster
Arbus
25
Practically a Master Poster
alex1050
-4
Newbie Poster
Arbus
25
Practically a Master Poster
alex1050
-4
Newbie Poster
Arbus
25
Practically a Master Poster
alex1050
-4
Newbie Poster
alex1050
-4
Newbie Poster
Lerner
582
Nearly a Posting Maven
alex1050
-4
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.