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?
 

cressida

Platinum Member
Sep 10, 2000
2,840
5
81
Overview:
- Read in the file
- Use args
- Quick search function
- Variable to keep track
- Output


Done, good luck
 

HappyCracker

Senior member
Mar 10, 2001
939
5
81
grep -o <string> <file> | wc -l
This only works for one search string. Handling two is something I don't know how to do