Whats wrong with this codes


Whats wrong with my program.
please help me correct my program because it does not do what i want it to do.

#include <stdio.h>
#include <conio.h>

void main()
{
char str[80];
int i,a,b,c,d,e;
clrscr();


printf("Enter Word: ");
scanf ("%c",& str[i]);
i=0;
a=1;
for(;;)
{
if ((((str[i] >= 65) || (str[i] >= 'a')) && ((str[i] <= 97) || (str[i] <= 122))) || (str[i] == 45))
{
for (b=str[0];a<=80;a++)
{
if (b==str[a])
printf("%c\n",b);
else
printf("%c\n",b);
b=str[a];
}
}
else
{
printf("Wrong Input!");
break;
}
}
getch();
}

The machine problem is:

Write a program that will identify word that the user inputs and determine how many times that word uses the certain letters, that the word contains. And the letters will be in alphabetical order.
The program must not accept a numeric value and special characters except the "-" that is needed in compound words as input .

Example :

I enter the word "letters"

The program must show:

e = twice
l = once
r = once
s = once
t = twice

If I enter the word "add5@6" with number or special character in the input word
the program will say "Wrong input" and will require the user to input another word.
Your for loop runs forever and i always remains 0.

Use for(; str[i]!='\0';i++)

There are a few more things as well, but I have to go to work now.
Topic archived. No new replies allowed.