![]() |
Help with a program in C(searching for a string).
Hello.
I've been given an assignment to write a program in C that can open a txt file and search for a string. It must then print the lines in which the string was found. I have the following code so far: Code:
#include <stdlib.h>I would really appreciate it if someone helped me with this. |
Re: Help with a program in C(searching for a string).
The problem was already solved in another forum. I want to apologize for cross-posting,
but the matter was urgent and I needed an answer fast. As a sign of responsibility, I will post the solution here: [IMG]file:///C:/DOCUME%7E1/Raz/LOCALS%7E1/Temp/moz-screenshot-1.png[/IMG]Requinix from the Dev Shed Forums and JackOfAllTrades from Dreamincode forums noted that strcmp returns 0 if the string matches, not 1, which was my mistake. Also my version of the program doesn't detect the string unless it's at some multiple of 8 characters from the beginning of the line. |
| All times are GMT +5.5. The time now is 02:41. |