Question: GET THIS ERROR WHEN I RUN THIS CODE. The assignment is to find the bug using gdb. HERE IS THE CODE #include #include /*Return the

 GET THIS ERROR WHEN I RUN THIS CODE. The assignment is

GET THIS ERROR WHEN I RUN THIS CODE. The assignment is to find the bug using gdb.

HERE IS THE CODE

#include

#include /*Return the result of appending the characters in s2 to s1.Assumption: enough space has been allocated for s1 to store the extracharacters.*/

char* append (char s1[ ], char s2[ ]) {

int s1len = strlen (s1);

int s2len = strlen (s2);

int k;

for (k=0; k

s1[k+s1len] = s2[k];

}

return s1;

}

int main ( ) {

char str1[10];

char str2[10];

while (1) {

printf ("str1 = ");

if (!gets (str1)) {

return 0;

};

printf ("str2 = ");

if (!gets (str2)) {

return 0;

};

printf ("The result of appending str2 to str1 is %s. ",append (str1, str2));}

return 0;}

gcc version 4.6.3 main.c: In function 'main': main.c:25:14: warning: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit- function-declaration] if (lgets (strl)) ( fgets /tmp/ccfko25j.o: In function "main': main.c: (.text+0x91): warning: the gets' function is dangerous and should not be used. strl rr str2 rr The result of appending str2 to strl is rrrr. strlrwrr The result of appending str2 to strl is rwrrwrwr. strldad str2 mom The result of appending str2 to strl is dadmomwr. strl

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!