You were close, the changes I made are in red and read the comments I added.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fin, *fout;
char text[81], text2[81], first[40], last[40], sale[40], car[40];
int lines;
int number; //no one ever has 4.3798 cars, this only needs to be an integer.
fin = fopen("/home/hp/iacs5/me9x/public/input.dat", "r");
fout = fopen("output.dat", "w");
if ( (fin == NULL) || (fout == NULL))
{
printf("file open failure\n");
exit(1);
}
lines = 0;
printf("\n");
fprintf(fout, "\n");
while( fgets( text, 81, fin ) != NULL )
{
lines++;
if ( lines % 2 != 0 )
{
sscanf(text, "%s%s%s", first, last, sale); //no need for spaces between each %s.
printf("Mr/Ms %s's sale was %s\n", last, sale);
}
else
{
sscanf(text, "%d%s", &number, car); //use %d for integer and don't forget to use an ampersand!
Also, fgets is only ever reading data into text, not text2 as you had here previously
printf("His/Her commision is %d\n", number); //again, %d for integer
}
}
getchar();
return 0;
}