0

Can somebody show me how to search and count for the string. If i have a set of data,i.e.

"0012", "0034", "0055"' "0099"
"0013", "0032", "0012","0099"

let's say i chose the 1st string(at the 1st line),"0012", and based on this string, i would like to search and count that string at the 2nd line.

My intention is to search and count that string from the different line.:rolleyes:

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by WaltP
0

what do you want to search for and what do you want to count? do you want to count the number of times "0012" appears in both lines (and the same for each of the other strings on line 1) ?

one way to do it is to create a structure that contains the word to search for and an integer that is the number of times that word appears in the other lines

struct count
{
    char word[20];
    int counter;
}

create and populate an array of those stuctures from the words in the first line, then read the second line and search each of the structures for the word. When found increment its counter, then go on to the next word in the second line. continue that until all the words have been read from the file. When finished, you will have a total frequency count for each word.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.