trying to create a code in C. First of all, I can't use the string.h library or any other that helps similarly. The input will be from command line like: ./program pattern file, I already succeed to open the file and write line of the file to an array, but now I have to compare the pattern a get with the line in file. If there is written the pattern, I have to printf the whole line.
For the input I use:
char array[1000]; // hope 1000 will be enough
char *pattern= argv[1];
For the scanning I use:
while (fscanf(f,"%c", &temp)!= EOF){
if (temp=='\n'){
Algoritm...
}
add to array( array[i++]=temp) - already works`
And If I get end of line, I do not When the '\n' ocures, I need to start the algorithm to find out if the small string is in the line.
My questions:
How can I compare these "strings"? efficiently?
How to get know the size of pattern I get as input? (I think I need that to do the algorithm)