string concatenate
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include <stdio.h> char* String_Concatenate(char* _Destination, char const* _Source); int main(void) { char greeting [20] = "hello "; printf("%s\n", String_Concatenate(greeting, "world!!")); return 0; } char* String_Concatenate(char* _Destination, char const* _Source) { int Destination_Index = 0; while (_Destination[Destination_Index] != (char) 0) Destination_Index++; int Source_Index = 0; while (_Source[Source_Index] != (char)0) _Destination[Destination_Index++] = _Source[Source_Index++]; _Destination[Destination_Index] = (char)0; return _Destination; } | cs |
0 개의 댓글:
댓글 쓰기