im trying to compare two strings length and print the longest but because i had to define the string as a static one i cant find a way to do it...help??
after this code the output is always s2's string. i understand its because the string declared as static. my question is how can i make the if-else work?? thx..
i was asked to create a class with a static char array limited to 255 and and another data member representing the string's length. then what im asked to do its creating two objects and compare them both and print the string with the bigger length...
I bet confusing terms: Not static, but static as in non-dynamic.
char array[255]; vs char * array = newchar [255];
Remove the word 'static' from the class.
Note: I could call s1.assign( text_of_entire_LOTR() ); and you would happily overwrite whatever happens to be after your 255 bytes. Modify your assign to check and guard against such input.