I have a stem file named myfile, it has 2 sub files : myfile.data and myfile.names.
Now I want to write a code where it will first check the .names file's last line and see whether there is a zero or not, if there is any other number other than zero then it will say noisy data. And if the .names files last line has a zero, then I need to read the .data file and do some operations on that .data file to produce a valid output.
Now below I am giving what I have tried to do:
    int main(int argc, char **argv)
    {
                char *path = argc > 1 ? argv[1] : "stdin";
                sprintf(path, "%s.names", argv[1]);
                
                
                FILE *in = argc > 1 ? xfopen(path, "r") : stdin;
                
                char buff[1024];
                int check = 0;
                fseek(in, 0, SEEK_SET); 
                while(!feof(in))
                {
                    memset(buff, 0x00, 1024); 
                    fscanf(in, "%[^\n]\n", buff);
                }
                
                if(strchr(buff, '0') != NULL){
                    check = 1;
                }
                
                if(check == 0){
                    printf("Noisy data...\n");
                }
                
                else if(check == 1){
                    
                    char *path = argc > 1 ? argv[1] : "stdin";
                    sprintf(path, "%s.data", argv[1]);
                    FILE *in = argc > 1 ? xfopen(path, "r") : stdin;
                    char buf[1024];
                    
                    if( fgets(buf, sizeof buf, in) == NULL ){
                        fputs("Input error\n", stderr);
                        return 1;
                    }
                    
                    ...
                    ...
                    produces the perfect output.
                }
            }
}
To execute this : <./executable_filename> <stemFileName> > <outputFileName>
So whenever I am doing : ./myFileName myfile output
It is showing me : myfile.names.data: No such file or directory
Why is it happening? Please help.
 
    