How to create a program compare character line?

Asked By 10 points N/A Posted on -
qa-featured

Hello experts,

How to create a program compare character line?

The programming languages that I know is C++, java and PHP programming language.

I hope you can give me a suggestion on what programming language will I choose to create a program compare character line?

And some downloadable sample codes will help a lot.

Thank you.

SHARE
Answered By 5 points N/A #175216

How to create a program compare character line?

qa-featured

Hello Deborah Hall,

Here you will get the sample code of program compare character line.

Sample is given below:

#include<stdio.h>
#include<string.h>

int main()
{
    FILE *ptr_file;
    char buf[200];
    char key[] = "test";
    int wordcount = 0;

    ptr_file = fopen("input.txt","r");

    while (fgets(buf,200, ptr_file)!=NULL)
    {
        if((strstr(buf,key)) !=NULL){
            wordcount++;
        }
    }
    fclose(ptr_file);
    printf("%d",wordcount);
}

The above code will help you to compare character line.

Thanks.

Related Questions