Hi All,
I am having problem with this piece of C code. I want to input two values. One is a char and another is a char * and I want to keep doing this in a while loop. However after the first iteration the program doesn't stop at the first scanf.
Please help me out here.
Thanks
Pravin.
----------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <ctypes.h>
int main(int, char*[]);
int main(int argc, char * argv[])
{
char *input;
char type;
int exit=0;
while (exit != 1) {
printf("Enter the type: "
fflush(stdin);
scanf("%c",&type);
if ((type == 'Q') || (type == 'q')) {
printf("\nThank you for using this program\n"
exit = 1;
} else {
printf("Please enter the input"
fflush(stdin);
scanf("%s",input);
}
}
return 0;
} //End of the line.
I am having problem with this piece of C code. I want to input two values. One is a char and another is a char * and I want to keep doing this in a while loop. However after the first iteration the program doesn't stop at the first scanf.
Please help me out here.
Thanks
Pravin.
----------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <ctypes.h>
int main(int, char*[]);
int main(int argc, char * argv[])
{
char *input;
char type;
int exit=0;
while (exit != 1) {
printf("Enter the type: "
fflush(stdin);
scanf("%c",&type);
if ((type == 'Q') || (type == 'q')) {
printf("\nThank you for using this program\n"
exit = 1;
} else {
printf("Please enter the input"
fflush(stdin);
scanf("%s",input);
}
}
return 0;
} //End of the line.