P
padh.ayo
Hi, I have a array structure called people
It is properly initialized to 100 array structure elements. Now, I'm
reading in from the command line a txt file, and I get them to open
correctly. In this .txt file, there is a name and a weight.
Josh 123.32
Jim 212.123
Steph 213.2
.... etc.
Now, I have this code:
FILE *ptr, *ptr1;
ptr = fopen(argv[1], "r"); //argv[1] is the txt file with al the
people/weight
while( (fscanf(ptr, "%s %f", people.name, &people.weight)) == 1
)
{
printf("%s %f", people.name, people.weight);
i += 1;
}
Why doesn't this work? Nothing gets printed out.
It is properly initialized to 100 array structure elements. Now, I'm
reading in from the command line a txt file, and I get them to open
correctly. In this .txt file, there is a name and a weight.
Josh 123.32
Jim 212.123
Steph 213.2
.... etc.
Now, I have this code:
FILE *ptr, *ptr1;
ptr = fopen(argv[1], "r"); //argv[1] is the txt file with al the
people/weight
while( (fscanf(ptr, "%s %f", people.name, &people.weight)) == 1
)
{
printf("%s %f", people.name, people.weight);
i += 1;
}
Why doesn't this work? Nothing gets printed out.