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
  • that doesn't mean that the code of strcpy is really the one in the library. it only says the proto type.

    That would be true for non-standard library functions. But C Standard Library functions are different: once you've included their respective Standard Header, any attempt at overwriting their implementation would cause undefined behaviour, so all bets would be off anyway.

Reply
  • that doesn't mean that the code of strcpy is really the one in the library. it only says the proto type.

    That would be true for non-standard library functions. But C Standard Library functions are different: once you've included their respective Standard Header, any attempt at overwriting their implementation would cause undefined behaviour, so all bets would be off anyway.

Children