Hi
Thanks very much for your reply. Its very appreciated.
I've only had very limited use of functions so its still a little bit lost on me. Sorry but i'm a bit lost with what you've put there. I see you've set the switch statement with (var). Then you have
choice_selection_function(leaving); and choice_selection_function(arriving); Are these functions that are set up elsewhere?
I'm also not sure where the void comes into it as i haven't used that before. Sorry but i've just started and its been a steep learning curve. I've put the whole section of code in so you can get a better idea of what i'm trying to do.
Code:
printf("\nEnter the station you will be leaving from by \nentering the corresponding number from the list below");
printf("\n 1 = Ashford\n 2 = Brentworth\n 3 = Canonbury Cross\n 4 = Dowgate\n 5 = Edbury\n");
printf(" 6 = Fenchurch Street\n 7 = Gresham\n 8 = Hampstead\n 9 = Islington\n 10 = Jamaica Road\n");
scanf ("%d", &leaving);
switch (leaving)
{
case 1:
system ("CLS");
printf("\nYou have selected : ");
printf(ash);
break;
case 2:
system ("CLS");
printf("\nYou have selected : ");
printf(brent);
break;
case 3:
system ("CLS");
printf("\nYou have selected : ");
printf(can);
break;
case 4:
system ("CLS");
printf("\nYou have selected : ");
printf(dow);
break;
case 5:
system ("CLS");
printf("\nYou have selected : ");
printf(ed);
break;
case 6:
system ("CLS");
printf("\nYou have selected : ");
printf(fen);
break;
case 7:
system ("CLS");
printf("\nYou have selected : ");
printf(gres);
break;
case 8:
system ("CLS");
printf("\nYou have selected : ");
printf(ham);
break;
case 9:
system ("CLS");
printf("\nYou have selected : ");
printf(isl);
break;
case 10:
system ("CLS");
printf("\nYou have selected : ");
printf(jam);
break;
}
printf(" as your leaving station\n");
do
{
printf("\nEnter the station you will be arriving at by \nentering the corresponding number from the list below");
printf("\n 1 = Ashford\n 2 = Brentworth\n 3 = Canonbury Cross\n 4 = Dowgate\n 5 = Edbury\n");
printf(" 6 = Fenchurch Street\n 7 = Gresham\n 8 = Hampstead\n 9 = Islington\n 10 = Jamaica Road\n");
scanf("%d", &arriving);
switch (arriving)
{
case 1:
system ("CLS");
printf("\nYou have selected : ");
printf(ash);
break;
case 2:
system ("CLS");
printf("\nYou have selected : ");
printf(brent);
break;
case 3:
system ("CLS");
printf("\nYou have selected : ");
printf(can);
break;
case 4:
system ("CLS");
printf("\nYou have selected : ");
printf(dow);
break;
case 5:
system ("CLS");
printf("\nYou have selected : ");
printf(ed);
break;
case 6:
system ("CLS");
printf("\nYou have selected : ");
printf(fen);
break;
case 7:
system ("CLS");
printf("\nYou have selected : ");
printf(gres);
break;
case 8:
system ("CLS");
printf("\nYou have selected : ");
printf(ham);
break;
case 9:
system ("CLS");
printf("\nYou have selected : ");
printf(isl);
break;
case 10:
system ("CLS");
printf("\nYou have selected : ");
printf(jam);
break;
}
printf(" as your arriving station.\n\n");
}while (leaving == arriving);
As you can see it should be possible to use the one switch statement for both selections as the choices are the same. Thanks again.