gets(name) not working if i do goto or main(); in turbo c++

35 Views Asked by At

`can you please help me, the code looks something like this basic:

#include<stdio.h>
int main()
{
char name[100];
int age;

clrscr();

printf("Enter Your Name: \n");
gets(name);
printf("Enter Your Age: ");
if(scanf("%d", &age)!=1)
{
goto basic;
}
return 0;
}

this code basically if you input any non integer value in age it is going to go back. but when it goes back the printf enter your name cannot be modified

is there any way that if i go main(); or goto basic i will be able to input something to enter your name?`

0

There are 0 best solutions below