Error while writing strcat() using pointers

前端 未结 4 841
忘了有多久
忘了有多久 2021-01-15 22:52

I am trying to learn C with The C programming Language by K&R. I am trying to write a the strcat() program using pointers.

char         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-15 23:39

    In this line:

    while(*s++ = *t++);
    

    you dereference s which points to one-past-the-end of the char array "stack". This causes segmentation fault error.

提交回复
热议问题