|
- #include <iostream>#include <cstdlib>#include <cstring>using namespace std;char * rxg(char * c, int cSize, const char * a, const char * b){ if(a != NULL && b != NULL) { strncpy(c, a, cSize-1); c[cSize-1] = '\0'; unsigned int cRemaining = (cSize - strlen(c)) - 1; strncat(c, b, cRemaining); return c; } return NULL;}int main(){ char a[] = "love "; char b[] = "C++!"; char c[10]; int csize = sizeof(c); rxg(c, csize, a, b); cout<<c<<endl; system("pause"); return 0;}
复制代码 |
|