Quote (evilironman @ Feb 28 2014 10:35pm)
char* stringCat(char* str1, const char* str2);
Appends a copy of string str2 to string str1. The first character of str2 overwrites the terminating null character of str1. The value of str1 is returned.
no cstring lib
Whats the problem? Provide your usage/code as well as error messages. Are you trying to come up with your own version of an existing function? What language are you using C or C++.
This is the most useless thread I've read to date...
Take a look at:
http://www.cplusplus.com/reference/cstring/strcat/ it looks like you just spelt it wrong.
Here is a untested version that does not use cstring functions, if this is what you are after. The code is bad and might not even work. It also forces the user to have a pointer waiting for the function as well as forces the user to clean up the allocated memory once done using it. Also if either string does not contain a nullbyte the function would break.
Code
char* stringCat(char* string1, char* string2) {
int len1 = 0, len2 = 0;
char* result = null;
while(string1++) { len1++ }
while(string2++) { len2++ }
result = (char*)malloc((len1 + len2) * sizeof(char));
while(--len1>0) { result[len1] = string1[len1]; }
while(len2-->0) { result[len2] = string2[len2]; }
return result;
}
This post was edited by AbDuCt on Feb 28 2014 09:04pm