This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

reentrant error!

#include <string.h>

void testok(void) reentrant
{ char buff[20];

buff[0]=1;

strcpy(buff,"hello");

//ok: buff = "hello"

}

void testfail(void) reentrant
{ char buff[20];

buff[0]=1; buff[2]=2;

strcpy(buff,"hello");

//fail: buff = "ello"

}

void main(void)
{ testok(); testfail();
}

Parents
  • And any change that makes the function called strcpy() behave differently from the C Standard's requirement causes undefined behaviour.

    no. it just not same as what you call standard. in the real world if you define the function it is not undefined behaviour. of course it assumes you KNOW how to write a proper function. you probably dont. LOL.

Reply
  • And any change that makes the function called strcpy() behave differently from the C Standard's requirement causes undefined behaviour.

    no. it just not same as what you call standard. in the real world if you define the function it is not undefined behaviour. of course it assumes you KNOW how to write a proper function. you probably dont. LOL.

Children