Go to the documentation of this file.00001
00002 #include "mbl_read_str.h"
00003
00004
00005
00006
00007
00008
00009 #include <vcl_cstdio.h>
00010 #include <vcl_cstring.h>
00011
00012 char* mbl_read_str(char *reply, int max_str_len, const char *q_str, const char *default_str)
00013 {
00014 char *new_reply = new char[max_str_len];
00015
00016 vcl_printf("%s (%s) :",q_str,default_str);
00017
00018
00019 vcl_fgets(new_reply,max_str_len,stdin);
00020 if (new_reply[0]=='\n')
00021 {
00022 if (reply!=default_str)
00023 vcl_strncpy(reply,default_str,max_str_len);
00024 }
00025 else
00026 {
00027 int i=0;
00028 while (new_reply[i]!='\n') i++;
00029 new_reply[i]='\0';
00030
00031 vcl_strncpy(reply,new_reply,max_str_len);
00032 }
00033
00034 delete [] new_reply;
00035 return reply;
00036 }
00037