You could use something like this:
void readData ( struct Data *people, FILE *inputFile, int elements );
A pointer to the array of structs, the file to read from, and the number of elements in the array so that you know where to stop reading. An additional option would be to include a return value which reports errors to the calling function.
Code:
for(i=0;i<numofelem;i++)
{
scanf("%s %d",tmp,&people[i].num);
people[i].string=(char *)malloc(sizeof(char)*(strlen(tmp)+1));
strcpy(people[i].string,tmp);
}
Your use of malloc here is very unsafe and more confusing than it has to be. The actual call would be safer and less crufty like so:
people[i].string = malloc ( sizeof tmp );
And every time you use malloc, never forget to check the return value. Trying to strcpy something into a NULL pointer will give you problems every time. And of course, don't forget that scanf reads from stdin and not a file. You'll need to use fscanf if you want to send a file to the function and read from it.
-Prelude