I Have main function:
Code:
int main(int argc, char *argv[]) {
int count = 0;
FILE *file_content;
int ch;
file_content = fopen(argv[1], "r");
while ((ch = fgetc(file_content)) != EOF) {
if ( ch == argv[2] ) {
count++;
}
}
printf("Characters found %d\n", count);
return (0);
}
where first argument is path to text file and second argument is character
for example ./program myFile.txt a
Problem is with comparing these two characters from second argument and character get from reading file. Variable ch must be int but in comparing I compare integer with pointer. How to convert this to same data type as second argument which is pointer to char?
I tried strcmp function too but same result.
Thanks for help.