Bogdan Maier
Bogdan Maier

Reputation: 683

How can i iterate in C a string by word

I need to make a program which takes as input on text file and output the same string with one replaced word; the main function will take 3 parameters (wordR, wordS, file). So can anyone help me with a good tip how I can scan the words in c?

Upvotes: 0

Views: 104

Answers (2)

Greg
Greg

Reputation: 1660

Go with strtok() or strtok_r() function.

Upvotes: 4

Jerry Coffin
Jerry Coffin

Reputation: 490148

The obvious possibility would be [fs]scanf's "%s" conversion:

char one_word[64];

fscanf(input_file, "%63s", one_word);

Upvotes: 2

Related Questions