-
What the string?!
why does lower[] print lower and upper case letters?
probably right in front of my face!
Code:
#include <stdio.h>
void alpha(char upper[26], char lower[26]);
main()
{
char upper[26], lower[26];
alpha(upper, lower);
printf("%s\n%s\n", upper, lower);
}
void alpha(char u[], char l[])
{
int i;
char X = 65;
char x = 97;
for(i = 0; i < 26; i++)
{
u[i] = X++;
l[i] = x++;
}
}
-
You need to have room for 27 chars in your arrays...you need room for the null terminator, and you need to add it.
-
BTW, I hope you don't use this technique in production code when in a company, since it isn't portable (i.e. it only works on ASCII platforms).
But if you're doing this just for school then it would be a lot more readable if you replace 65 with 'A' and 97 with 'a' so people don't have to look up an ASCII chart to see if it's right or not.