其实这个问题挺无聊,不过我左右无事,所以......
& m2 U: B7 Y2 F- l4 fchar *str_func( char *target_str, char *source_str)
* V# n( {7 i0 n5 o$ t{
% u6 |6 N3 v& w int i ;
: N3 Y, N0 G, t0 u6 P for( i = 0; i < strlen(source_str); i++ )
5 g5 w6 \. e1 C7 {0 t4 P {( S1 v6 A3 u5 f" w! f: s
target_str[2*i] = source_str;* C/ B. Q- L( L7 Q: e$ ~
target_str[2*i+1] = ' ';. J- Z1 P- s# p
}
9 _& o P M- @5 L" O return target_str;; W, L6 h" ^2 y
}
0 i8 p) d8 {) p- L& b
# v3 d4 Q8 g& H& N9 X' i- ]int main(void)
$ P2 b( w; a# C* u2 E5 G/ O# |' I{
, @; `+ D1 D+ p char *source_str = "12345";
' T. |' ~, c- g: B+ X9 b char *target_str;
. v7 M% y7 P! @# L
! a {) n% J# a- W) h2 @& b3 J) q target_str = malloc( strlen(source_str)*2 );
% R9 z$ a. ]! o2 H% U5 G/ U I str_func(target_str, source_str);
9 {1 G; l: f6 Y; {- n+ s; l( D printf("%s ---> %s\n", source_str, target_str);5 @4 a3 f) w w( `2 c7 O- C
5 _" g* D7 t7 A% e# U( D free( target_str );
3 e+ o/ N! Z! }/ k$ L return 0;
0 N6 d8 e: d7 Q/ i8 f}8 m3 s$ P/ c+ S$ z
. ]. r0 {1 u8 Q2 P' L; d* t$ ~