Originally posted by CAP
In my version I was trying to compare the value of 'd' to the cases, how does yours work? I can't see how or what you are checking...
Well, in CAP's code this happened
Code:
scanf("d"); /* Wrong, as previously highlighted */
switch(d)
{
case 'a':
printf("This is line 'a'");
case 'b':
printf("This is line 'b'");
case 'c':
printf("This is line 'c'");
}
And in jerryvtts's code, this happened:
Code:
if (fgets(input, BUFSIZ, stdin) != NULL)
{
sscanf(input, "%d", &d);
}
switch (d)
{
case 1: printf("This is line 'a'"); break;
case 2: printf("This is line 'b'"); break;
case 3: printf("This is line 'c'"); break;
default: puts(" You didn't enter a 1 or 2 or 3"); break;
}
The structure is basically the same, it just that jerry's will actually compile and run 
Also, note that jerry's case statements are checking against numbers, whereas CAP's are checking against character constants.
CAP, quick question, why ask the user to enter 1, 2 or 3, then check their input again a, b and c? Sounds a bit fishy to me 
jerry, please can you use code tags for the code (see my sig for an example). It helps make the code readable by keeping the layout as it is in your editor. Thanks.