@@ -37,21 +37,21 @@ int load_lang(const char *file_name)
37
37
int index = 0 ;
38
38
sscanf (buffer , "%s %i = \"%[^\"]" , var_name , & index , value );
39
39
if (strcmp (var_name , "zero" ) == 0 )
40
- sprintf (digits .zero , "%s" , value );
40
+ sprintf (digits .zero , "%s- " , value );
41
41
else if (strcmp (var_name , "ones" ) == 0 )
42
42
{
43
43
digits .ones [index ] = malloc (strlen (value ));
44
- sprintf (digits .ones [index ], "%s " , value );
44
+ sprintf (digits .ones [index ], "%s- " , value );
45
45
}
46
46
else if (strcmp (var_name , "tens" ) == 0 )
47
47
{
48
48
digits .tens [index ] = malloc (strlen (value ));
49
- sprintf (digits .tens [index ], "%s " , value );
49
+ sprintf (digits .tens [index ], "%s- " , value );
50
50
}
51
51
else if (strcmp (var_name , "hundreds" ) == 0 )
52
52
{
53
53
digits .hundreds [index ] = malloc (strlen (value ));
54
- sprintf (digits .hundreds [index ], "%s " , value );
54
+ sprintf (digits .hundreds [index ], "%s- " , value );
55
55
}
56
56
else if (strcmp (var_name , "out_range_err" ) == 0 )
57
57
{
@@ -77,6 +77,7 @@ int load_lang(const char *file_name)
77
77
char * digit_to_word (int num , char * plus_str )
78
78
{
79
79
char * str = malloc (2048 );
80
+ sprintf (str , "\b" ); // without this line the output will have some random characters in the beginning and I don't know why
80
81
if (num > 19 )
81
82
{
82
83
strcat (str , digits .tens [num / 10 ]);
@@ -92,7 +93,7 @@ char *digit_to_word(int num, char *plus_str)
92
93
char * num_to_word (long int num )
93
94
{
94
95
char * str = malloc (2048 );
95
- sprintf (str , "" ); // without this line the output will have some random characters in the beginning and I don't know why
96
+ sprintf (str , "\b " ); // without this line the output will have some random characters in the beginning and I don't know why
96
97
97
98
if (num == 0 )
98
99
{
@@ -130,6 +131,7 @@ char *num_to_word(long int num)
130
131
else if ((num / 100 ) % 10 )
131
132
strcat (str , digit_to_word (((num / 100 ) % 10 ), digits .hundreds [4 ]));
132
133
strcat (str , digit_to_word ((num % 100 ), "" ));
134
+ str [strlen (str ) - 1 ] = 0 ;
133
135
134
136
return str ;
135
137
}
@@ -151,7 +153,7 @@ int main(int argc, char **argv)
151
153
fscanf (stdin , "%s" , user_input );
152
154
if (sscanf (user_input , "%li" , & num ) == 0 )
153
155
{
154
- fprintf (stderr , "%s\"%s\" %s" , UI .nan_err [0 ], user_input , UI .nan_err [1 ]);
156
+ fprintf (stderr , "%s\"%s\" %s\n " , UI .nan_err [0 ], user_input , UI .nan_err [1 ]);
155
157
return -1 ;
156
158
}
157
159
if (num > 1109999999 )
0 commit comments