guest
guest

Reputation: 9

How to create code that searches for a word in a .txt file and counts the amount of times it occurs in C?

FYI I am fairly new to coding in C. I am looking for a way to search a .txt file for a certain word that is inputted by the user and counts the number of times it occurs within the .txt file. I currently have the .txt file in a 2D array. I have no idea how to even start. Please help!

Upvotes: 0

Views: 78

Answers (1)

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81724

You can start with the standard library function strstr. Read the description, and think about how you'd apply it to your 2D array (of, presumably, char*).

Upvotes: 1

Related Questions