hello
i have the following file:
11
Lockers, Daniel;Engineer;53500
Adamson, John;Manager;77500
Newhall, Bob;Programmer;40000
Brown, James;Clerk;28000
i need to put each employee into a struct and then each struct into an array.
so far i did this:
else
{
fscanf(sourcefile,"%d\n",&count);
printf("%d\n",count);
Array=(employeeType *)malloc(sizeof(employeeType)*count);
for(i=0;i<count;i++)
{
fscanf(sourcefile,"%s",Array[i].name);
fscanf(sourcefile,"%s",Array[i].job);
fscanf(sourcefile,"%d",&Array[i].salary);
}
}
for(i=0;i<count;i++)
printf("The name of employee %d is %s his job is %s and his slary is %d\n", i+1, Array[i].name,Array[i].job,Array[i].salary);
free(Array);
this works only if the name, job and salary of the employees are separated by space.
can anyone tell me how i can read the stings when they are separated by ";" as the example?
thnks