Can anyone tell me why it displays more than 1 line of the same?
This program everytime twice displays the line for the user to enter C, D or F. Why is that?
Also, if the user enter more than 1 letter for the first prompt, the C, D, F line is printed multiple times in relation to how many letter the user entered.
Help Appreciated
Code:
#include <stdio.h>
#include <process.h>
#include <conio.h>
int sort_bytes();
int create_screen();
int initialise_com_port();
char input;
char input2;
int main(void)
{
initialise_com_port();
printf("This is the Data Packet Analyser program\n");
printf("This program does...\n");
printf("Enter 'C' to make a capture: ");
scanf("%c", &input);
sort_bytes();
create_screen();
getch();
return 0;
}
int initialise_com_port()
{
printf("\nHello from initialise_com_port\n");
}
int sort_bytes()
{
printf("\n\nHello from sort_bytes!");
}
int create_screen()
{
printf("\n\nHello from create_screen!\n");
do
{
printf("\n\nEnter 'C', 'D', or 'F': ");
scanf("%c", &input2);
switch ( input2 )
{
case 'C' : printf("\nFunction sort_bytes and function create_screen");
printf(" is called in.");
break;
case 'D' : printf("\nFunction create_file is called in");
break;
}
}
while ( input2 != 'F');
printf("You have decided to exit from the program\nPress Enter");
}