#include <iostream>
int main(int argc, char *argv[])
{
int count=0;
if (argc<2)
{
std::cout<<"Wrong No Of Parameters";
exit(1);
}
FILE *file;
file=fopen(argv[1],"r");
char c;
while((c=getc(file))!=EOF)
{
if (c=='\n')
{
count+=1;
std::cout<<std::endl;
}
else
printf("%c",c);
}
std::cout<<"\nNo Of Lines In the File :"<<count+1;
fclose(file);
return 0;
}
My program crashes whenever i type this in command line
c:\test Text.txt