#include<string>
int str_len( const char * const src)
{
int len=0;
while(src[len])
{
len++;
}
return len;
}
int str_copy( char * &dest, char * src) // removed (const) to sore the string in dest.By using const,we dont have the
// access to store the string.By using ampersand we can return the copied string as well as
// the length.
{
int len=0;
while(src[len])
{
dest=src;
len++;
}
return len;
}
int str_cat( char * &dest, char * src1, char * src2) // not working
{
int len=0;
while(dest=src1=src2)
{
dest++;
src1++;
src2++;
len++;
}
return len;
}
int str_to_upper_case( char * &dest, char * src)
{
int len=0;
while(src[len])
{
dest=src-32; //converting in to uppercase
len++;
}
return len;
}
int main()
{
char*s1="Testing the function ";
char*s2="Testing str_cat";
char*s3="abcd";
char*s4;
int length_s1=str_len(s1);
int str_copy_len=str_copy(s1,s2);
//int concatenate=str_cat(s3,s1,s2);
int upp_case=str_to_upper_case(s4,s3);
return 0;
}
please point out the mistakes...my concatenate function is not working as well as well as upper case function return the len accrately but didnt show the upper case character...it shows a square box while debugging.