Greetings,

how can i write a search program to search a user entered string saved in an array, in a text file using File Operations in C. Specially using fseek() function.

Plz reply,
Thanks in advance..!

Recommended Answers

All 3 Replies

You don't need fseek to do this, just read the file sequentially using (for example) fgets and look for the substring using strstr. Very simple.

yes, i was doing that. i searched for the string using strstr function. but when i tried to print from the position just after the last character of the searched string, by using a pointer, sumthing went wrong with the logic.
Is there any other way to do this ?

>sumthing went wrong with the logic.
Then you should fix your logic, not start over from scratch. Clearly the problem isn't with the solution, it's with how you implemented the solution.

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.