Well, I've recoded some things after finding out I didn't need to use file pointers. Here's my code that I got working:
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char a[] = "name";
char b[] = "hours";
char c[] = "rate";
char d[] = "pay";
float hours;
float rate;
char name[256];
char * tmp = malloc(256);
printf("%-20s %10s %10s %10s\n", a, b, c, d);
/* do the first scan */
scanf("%f%f", &rate, &hours);
while(fgets(name,256,stdin) != NULL)
{
/*if a new line is found set it to NULL*/
if( ( tmp = strrchr( name, '\n') ) )
{
*tmp = '\0';
}
/*prints out the name, rate, hours, and amount to be paid*/
printf( "%-20s %10.2f %10.2f %10.2f\n", name, rate, hours, rate*hours );
/*reads in the rate and hours*/
scanf( "%f%f", &rate, &hours );
}
return 0;
}
I compile as follows: gcc -Wall -ansi main.c
run: ./a.out < input.txt
After I figured out thats how the text file was read in, it made it simpler. I made it harder than it needed to be. thanks for all the help offered...I'm sure I'll be needing some more as time goes on.
once again, thanks...