The purpose of this code is to open a file, read a passage and delete any word that is "secret", it is then to save the new passage to a new file.
Problem:
[Warning] passing arg 1 of `strcmp' makes pointer from integer without a cast
I think I know what the warning is telling me but I don't know enough to fix it.
Any idea what is wrong and how I can fix it? I think my code should work except for what ever that warning is.
I hope I entered the code correctly here, I am new to this type of forum posting.
#include <stdio.h>
int main (int argc, char *argv[]) //Passing arguemnts to main function.
{
FILE *in, *out; //Declaring both pointers as files
int c;
if( argc != 3 ) { //Checking that there are a total of three arguments passed
fprintf (stderr, "Need two file names\n"); //If there are not three arguments, it will cause a standard error
return 1;
}
if ( (in = fopen(argv[1], "r")) == NULL ) { //First pointer that will open the file in read only mode file will onle be read
fprintf (stderr, "Cant read %s.\n", argv[1]); //If the file is not located it will return a null file returning an error
return 2;
}
if ( (out = fopen (argv[2], "w")) == NULL ) { //Second pointer that will open the file in write mode that will be written into
fprintf (stderr, "Cant write %s.\n", argv[2]); //File will automatially be created by the the terminal
return 3;
}
while( (c = getc(in)) != EOF) { //While loop will get all the characters stored in the read file and save then onto c
if (strcmp(c, "secret") == 0) { //If statement will check for the letter s and replace it will a space.
c = "_____";
}
else
putc(c,out); //After the caharacters have been stored in c, all the caharacters will then be transfered into the the out file
}
printf ("File has been copied. \n");
fclose (in);
fclose (out);
return 0;
}