#include
#include
#include
void main ()
{
char *imsi;
unsigned int i;
int val;
char *dest;
imsi = \"4057501
The behaviour of this code is unpredictable because the pointer dest is used before it is initialised. The difference in observed behaviour is only indirectly related to the root cause bug, which is the uninitialised variable. In C it is the programmers responsibility to allocate storage for the output of the strncpy() function and you haven't done that.
The simplest fix is to define an output buffer like this: char dest[10];