You have a start there but I think you might (should) be getting some errors? (I sure did)
This should get you running:
Code:
/* orderstrings1.c */
#include <stdio.h>
#include <conio.h>
/* use to pause OR to empty leftovers in stdin buffer */
void PAUSE(void){int c; while((c = getc(stdin)) != '\n' && c != EOF); }
/* use instead of scanf("%c", &char) and getchar() */
int mygetchar(void){ int c; c = getc(stdin); PAUSE(); return c; }
int main()
{
char b, c, d;
/*char a[i] = {'.... You can't do that unless i has a value
char a[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','O','P','Q','R','S','T','U','V','W','X','Y','Z','\0'};
Note the '\0' at end
...works but this does the same thing with less effort:
(and how about some lower case letters too) */
char a[] = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ";
int i = sizeof(a) - 1; /* get the length of the string and stor in i */
printf("i= %d \n", i);
/* I don't think you want to put anything else in 'a' do you? maybe in 'd' ?
printf ("Input a letter");
scanf("%c",&a);
*/
/* printf ("Input a letter"); I added ': ' to improve appearance */
printf ("Input a letter: ");
scanf("%c",&b);
PAUSE();
/* CAUTION: Using scanf() for %c haracters is overkill and causes another
problem. Scanf() will read the first char it encounters and leave any
other input in the input buffer which includes the \n from hitting return
key when your finished entering. That \n will be picked up by the next
call to scanf() and so it being satisfied with \n as it's character it
will end leaving you with a \n as value of c. I made a PAUSE(); function
(see at top) which will clean that up.
I also left a 'mygetchar()' to use instead of scanf(%c) or regular getchar()
which will also leave unused chars in the stdin buffer. */
printf ("Input a letter: ");
c = mygetchar();
printf ("Input a letter: ");
d = mygetchar(); /* I added this for unused variable 'd' */
/* ok so what do you want to do here???? Your move... */
for (i = 0; i < 3; i++)
{
printf ("%c", a[i]);
printf ("\n");
}
/* printf ("%c %c %c", a, b, c); again with the string a and no d */
printf ("%c %c %c ", b, c, d);
/* getch(); this will do the same thing and you won't need conio.h */
PAUSE();
return 0;
}
So you want to alphabetize strings? You will need to input strings then.
Happy's suggestions look good for that.