#include<stdio.h>
#include<conio.h>
main()
{
int i;
char c, text[30];
float f;
printf("\nEnter Integer : ");
scanf("%d",&i);
printf("\nEnter Character : ");
c = getch();
printf("\nEnter String:");
gets(text);
printf("\nEnter Float:");
scanf("%f",&f);
printf("\nInteger : %d",i);
printf("\nCharacter : %c8",c);
printf("\nString : %s",text);
printf("\nFloat : %f",f);
getch();
}
Why is this simple program not able to read a string
using the gets()
function? What else should I use to correct it? Well it it worked in Turbo C in my old 32-bit PC but not here...