#include <iostream>

int main(int argc, char *argv[])
int count=0;
if (argc<2)
           std::cout<<"Wrong No Of Parameters";
FILE *file;

char c;
   if (c=='\n')

std::cout<<"\nNo Of Lines In the File  :"<<count+1;

return 0;

My program crashes whenever i type this in command line
c:\test Text.txt

Sorry i posted this...i know i am making very serious mistakes in the code....getting confused in c and c++...

No need to reply...thanx anyways

Getting C and C++ all mixed is common!

mixing c and c++ file operations is undesirable, but not something that will crash the program. Probably the reason it crashed is that there is no check to see if the file was opened successfully. You can't just assume that. The second reason is that c is defined as char, but getc() returns an int. change c to an int and it should detect EOF correctly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.