Question: why can this array hold more elements than how many it was initialised? (result array is initialised to 5 but at the end it has
why can this array hold more elements than how many it was initialised? ("result" array is initialised to 5 but at the end it has strlen 16)
char oldword="abcde";
char newword="a";
char sentence="abcdabcdabcdabcd"
int j; int k = 0; int len_old = strlen(oldword); int len_new = strlen(newword); int lenS = strlen(sentence); int maximum_result = (lenS / len_old + 1) * len_new + 1; // think !? char result[maximum_result]; for(int i=0 ; i printf("%s",result); However, when I try to use for loop to put 10 numbers into a size-5 array, I got abort trap. Why is that?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
