I wrote this simple c code in microsoft visual C ++ 2010.
#include<stdio.h> #include<conio.h> void main() { char title[20], artist[30]; int numtrack, price; char type; printf("Enter the title of CD \n"); scanf("%s",title); printf("\nName of the artist \n"); scanf("%s",artist); printf("\nEnter the type of CD(enter a for album and s for single)\n"); scanf("%c",&type); printf("\n Enter the number of tracks \n"); scanf("%d", &numtrack); printf("\n Enter the price of the cd \n"); scanf("%d", &price); printf("%s\n%s\n%c\n%d\n%d\n",title, artist, type, numtrack, price); getch(); }
It means that
Enter the title of CD ranjit Name of the artist mahanti Enter the type of CD(enter a for album and s for single) Enter the number of tracks 4 Enter the price of the cd 4 ranjit mahanti 4 4
I cannot understand why it is not waiting for input for a type variable? Can someone explain this please? Thanks in advance.
source share