Please write a C function that converts a given integer into a string

xiaoxiao2021-03-06  44

#include #include char * str_from_i (int i_in, char * str_out) {INT T_OP_FLAG = 0; INT T_I_IN; INT T_NUM_COUNT = 0; if (i_in <0) {t_op_flag = 1; i_in * = (- 1); * STR_OUT = '-';} // printf ("% d / n", t_num_count); t_i_in = i_in; while (t_i_in / = 10) T_Num_count ; //printf ("% D) / n ", t_num_count); str_out = t_num_count; str_out ; * STR_OUT = '/ 0'; str_out--

Do {* str_out = i_in% 10 '0'; // printf ("% C / N", str_out); if (i_in / = 10) STR_OUT -; if there R Some Num ForWord, So Str_out Go Back} While (i_in% 10); /// if there R Some Num, so loop

IF (t_op_flag) STR_OUT--; RETURN STR_OUT;} int main () {INT i; char str_out [100]; while (1) {scanf ("% d", & i); str_from_i (i, str_out); Printf "% s / n", str_from_i (i, str_out));}}

转载请注明原文地址:https://www.9cbs.com/read-68877.html

New Post(0)