0

The program is interactive.... But after putting scanf it cannot clear the first statement, anyone knows the solution

char firstn[100];
char secondn[100];
printf("\n\bPlease Enter Your First Name:  ");
scanf("%s", &firstn );
fflush(stdout);
Sleep(1234);
printf("\r\bPlease Enter Your Second Name: ");
scanf("%s", &Secondn);
joshmat
  • 11
  • 2

1 Answers1

1

To clear the screen you can use:

... // Other headers
#include <stdlib.h>

int main{
   ... // Code
   system("clear"); // or system("cls"); on Windows.
   ... // Code
}

And this should work for your purposes.

If you need to clear a specific line only, you can use ncurses as this Q&A demonstrates.

Rivasa
  • 6,510
  • 3
  • 35
  • 64