hi
i have coded a program such that when a string with a hyphen (-) is entered it should display all the letters between characters on either side of string.
input is harsha-gas
output is a b c d e f g
but i am getting an error in the program....could anyone pls help
thanks
also in case if input is harsha-9gas then it should print a-z then A-Z in caps and 0-9
how do i do this
could anyone give me a clue
thanks
Code:
#include<stdio.h>
#include<string.h>
main()
{
char a[100],p,q;
int i,j,k,s;
printf("enter the string seperated by a -");
gets(a);
printf("%s",a);
s=strlen(a);
for(i=0;i<s;i++)
{
if(a[i]=='-')
{
p=a[i-1];
q=a[i+1];
}
if(p>=97&&p<=123)
{
printf("%c ",p++);
}
if(p==q)
break;
else
if(p>=65&&p<=91)
{
printf("%c ",p++);
}
}
printf("%c",q);
}
then it must print