jeudi 26 mars 2015

i am getting error in this c program

i am trying to implement this c program , i want to expand strings eg a-z to a b c d ...z etc when i put the input string as a-z i dont get the o/p but when i use the input string as az or without using the - i get the desired o/p



#include<stdio.h>
main()
{
char s1[20] = "a z", s2[10], s3[30];
int k = 0, i = 0;
while (s1[i] != '\0')
{
if((s1[i] >= 65 && s1[i]<= 90) || (s1[i] >= 97 && s1[i]<= 122))
s2[k]=s1[i];
i++; k++;
}
s2[k] = '\0';
for (int m = s2[0] ; m <= s2[1] ; m++)
printf("%c ",m);
}

Aucun commentaire:

Enregistrer un commentaire