Hi,
I need to use strcat() to concatenate two strings, call them sFirst and sSecond. sFirst is allocated as follows:
sSecond is allocated in the same way. I concatenate them
as:
Now, the literature I've read says that strcat will contatenate sSecond to the end of sFirst, returning then sFirst. My question is - what happens if there isn't enough contiguous memory to append sSecond in its entirety to the end of sFirst? Is another char* allocated, assigned-to, and returned? And - if so - does it automatically free the original sFirst memory?
Thank you!
dora c
I need to use strcat() to concatenate two strings, call them sFirst and sSecond. sFirst is allocated as follows:
Code:
char* sFirst = (char*)malloc( sizeof(char) );
sSecond is allocated in the same way. I concatenate them
as:
Code:
sFirst = strcat( sFirst, sSecond );
Now, the literature I've read says that strcat will contatenate sSecond to the end of sFirst, returning then sFirst. My question is - what happens if there isn't enough contiguous memory to append sSecond in its entirety to the end of sFirst? Is another char* allocated, assigned-to, and returned? And - if so - does it automatically free the original sFirst memory?
Thank you!
dora c