Fopen return NULL based on
now I have one file to read and I want to output on console but it throws an error as fp return NULL here a snippet
#include<stdio.h>
int main(char argc,char **argv)
{
if(argc < 2)
{
printf("Usage:\t");
printf("Hash File path");
}
printf("Hash File : %s\n", argv[1]);
FILE *fp = fopen("argv[1]","r");
if(fp == NULL)
{
fprintf(stderr,"Can't open %s\n", argv[1]);
}
else
{
char buff[100];
while(!feof(fp))
{
if(fgets(buff,100,fp) == NULL) break;
fputs(buff,stdout);
}
fclose(fp);
}
return 0;
}
whenever I pass file Path E:\design\test.txt from the command line it always shows error report "Can't open...." like this
so the confusion is
why Fopen Failed to read from Command line?