Your code to allocate and read the string is wrong. You are allocating an array of 1000 pointers. You meant to write:
char num[1000];
scanf("%s", num);
The rest of your code is full of errors too. You meant to initialise i to 0. And you need to set it back to 0 before the second loop. And your second loop runs to 1000 and so accesses uninitialized elements of num.