I'm trying to write my own versions of strcat, strcpy and strcmp... They work fine right now it seems
but I would appreciate any comments and/or suggestions how to make them better ( I assume they aren't perfect )
if you know of good corrections which should be made.
Code:
//My own strcat...
char* strcat(char text1[], char text2[])
{
int i=0, j=0;
while ((int)text2[j] >0)
{
if ((int)text1[i] > 0)
i++;
else
{
text1[i] = text2[j];
i++;
j++;
}
}
return text1;
}
//My own strcpy...
char *strcpy(char text1[], char text2[])
{
int k=0;
while ((int)text2[k] > 0)
{
text1[k] = text2[k];
k++;
} text1[k] = '\0';
return text1;
}
// My own strcmp...
bool strcmp(char text1[], char text2[])
{
int i=0;
while ((int)text1[i] == (int)text2[i] && (int)text1[i] > 0)
i++;
if (text1[i] == text2[i])
return true;
else return false;
}