Help Writing a Linux C Program

Connoisseur

Platinum Member
Sep 14, 2002
2,470
1
81
Hey guys, i'm taking a linux programming course and the warmup assignment is to write a program which reads a string from a file and counts the occurrences of a user inputted string in the string that was read from the file. For example, if the file contained "abcdefghij" and the program name was "frequency", then the user would input "frequency ab gh" and the output would be:
1
1

My biggest problem is the system calls. I don't remember the read file command or the command that reads the user-inputted arguments as I haven't done linux programming in many years. could someone help me?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
If it's straight C the read file command is cryptically called "read". As for reading from STDIN, I think you want fgets, but I'm not 100% sure. Actually you could use fgets to read from both filehandles if you wanted.