From ea636383ae8ed420335b74c94f3c804292ad2ba4 Mon Sep 17 00:00:00 2001 From: Calson Noah Date: Fri, 19 May 2017 09:27:04 +0100 Subject: [PATCH] completed function to write new user --- functions_for_cmd_typist.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/functions_for_cmd_typist.h b/functions_for_cmd_typist.h index 3a1381f..3614744 100755 --- a/functions_for_cmd_typist.h +++ b/functions_for_cmd_typist.h @@ -630,5 +630,22 @@ void test_new_user(char *name)//used to create new user name fprintf(stderr, "%s %s\n", name,"too short, cannot be a user name");//exiting when a wrong value is entered exit(EXIT_FAILURE); } - + //char ch='z';//setting a value so that the value initialized by default is never y or n + printf("WARNING: All saved data will be erased \n" + "Do you want to continue: [y/n]:"); + if(get_only_char()=='n') + exit(EXIT_FAILURE); + FILE *fp; + if((fp=fopen("./speed/user_speed.info","w"))==NULL) + { + fprintf(stderr, "%s\n", "Fatal Error, Some files are missing"); + exit(EXIT_FAILURE); + } + rewind(fp); + fprintf(fp, "%s\n", name); + if(fclose(fp)) + { + fprintf(stderr, "%s\n", "Fatal Error, Unable to close some files\n"); + exit(EXIT_FAILURE); + } } \ No newline at end of file