I am looking to have a portable code (which works in both Pelles C IDE and in the Linux box).
When I use below code (code snippet below) in Pelles C, it works most of the time (Not yet found the failure).
And when I take it to Linux environment, it fails with Segmentation fault.
To my guess, due to a vague coincidence, this problem is not noticed in Pelles environment.
My intent of this message is, what is that helping not showing in Pelles C ?
(One solution as I know is that allocate one more character space to hold end character.
But, I am looking to have this code to work in Linux, since it is working in Pelles C IDE.)
Code snippet.
struct node *f1(char *linebuf)
{
char *pdest = NULL;
pdest=linebuf;
char *tmp=NULL;
//tmp is used to hold linebuf
tmp = (char *)calloc(strlen(linebuf), sizeof(char));
strcpy(tmp,linebuf);
...
...
...
}