hi using c language plz help me with this hwk you will need to parse a file of words 5151876
Hi Using C language, Plz help me with this hwk!
You will need to parse a file of words to determine if there is a valid time in the file. Read each “token” and see if there are any of them that have the following format:
XX:XXPM or XX:XXAM
Either one of these will constitute a valid time if the X’s are actually valid numbers. For example:
5:99PM is NOT a valid time. 5:03AM is. 14:48 is NOT a valid time, 12:15PM is (use 12-hour clock).
Use the following function prototypes:
int main (int argc, char *argv[])
Main function that will open an input file and print out the final totals as seen in the sample output.
void readToken(FILE *fPtr)
This function will receive a file pointer and read a token (word) from the file to be processed by checkTime().
void checkTime(char *token)
This function will take a character string that points to a token and will check it to see if the token is a valid time. It will count the number of tokens and calculate the number of valid times. static int should be helpful here.
Sample Output
./a.out
Improper number of parameters – try again
./a.out token.dat
4:15PM
3:59AM
1:15AM
There were 47 tokens in the file.
3 tokens were valid times.
End of program.
//////////////////////
this is the token.
10:23pm
abc123:45
12:12am
1:02pm
10:32
14:23pm
10:88am
12:20:
12::20
1:1
12:20:pm
12::20pm
1:1am
12:20aa
12:20pb
12:20amm
12:20pmm
:12:20pm
xxx