jmt jmt - 3 years ago 134
C Question

I created a program in c which print out a statement , then after some second it clear and replace with a new printed statement

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 );
printf("\r\bPlease Enter Your Second Name: ");
scanf("%s", &Secondn);

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download