Hello everyone! I sure wish I would have known about this place befroe now, it would have saved some long nights. I am having probems with arrays. The situation is this read all the lines from a file and store it into an array. Once you do this, you have a character array. All your further operations should be done on the array. create a function called "Matcher". The Matcher function should go through the entire array and find how many times the string or character pattern 'aba' occurs in the entire array.
On finding a match, the program should display the index number of the array at which the string pattern started.
Once the search is complete, the program should display how many times it found the string or character pattern 'aba' in the entire array or more appropriately, in the file.
If the number of matches is zero, the program should output "Search String NOT found".
For programming purpose use this file( "file.txt"). I tried to write it with out any help and am finding I need some. I am a little older and you know what they say about teaching an old dog new tricks.
lilpil02
0
Newbie Poster
Recommended Answers
Jump to PostPost the code you've got between CODE tags. Quid pro quo.
Jump to Post>if(i=a)
This is assigning the value of a to i and then evaluating whether i is nonzero. Use if(i==a).
Why do you take input into an array of int if it is supposed to be an array of char?
>void main()
Use int main().
Jump to PostTry adding some debugging statments to help you as you go. Just use cout to display something you may be curious about. This will be one way to answer your own questions as you go.
Are you required to do user input char by char, or are you allowed …
All 9 Replies
Dave Sinkula
2,398
long time no c
Team Colleague
lilpil02
0
Newbie Poster
Dave Sinkula
2,398
long time no c
Team Colleague
lilpil02
0
Newbie Poster
lilpil02
0
Newbie Poster
Dave Sinkula
2,398
long time no c
Team Colleague
lilpil02
0
Newbie Poster
Dave Sinkula
2,398
long time no c
Team Colleague
lilpil02
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.