I want to be able to have a user input a-z or c-z or c-p or whatever and have it return the actual letters between those two. I figured I would have to use ASCII numbering so I could use these steps:
1) Look for '-', if true
2) Look at first char that was input(char a in a-z), find ASCII #
3) Look at last char that was input (char z in a-z), find ASCII #
4) Print first letter based on ASCII #, then with a loop print the rest, up until the last letter in a-z (in that case being z).
Here's my code so far, but I think it's way off, I don't have a good grasp on the ASCII stuff in C, if that's what I even need.
#include <stdio.h>
#include <string.h>
void expand (char s1[], char s2[]){
int j = 0;
for (j; j <= s1[j-1]; ++j){
if(s1[j+2] = '-'){
while(j <= 70){
++j;
printf("%c\n", s1[j]);
}
}else{
printf("Invalid\n");
}
}
}
int main(){
int g = 40;
char s1[g], s2[g];
printf("Please enter a-z or an equivalent:\n");
scanf("%s", s1);
expand(s1, s2);
return 0;
}
Thanks for the help guys!