Thanks Pedro.
  Can u explain the IF_CONDITION below?
  Thanks in advance
  asma
Pedro Izecksohn <[EMAIL PROTECTED]> wrote:
  asma sabir wrote:

I'm doing OS course in Linux where I m not understanding the command line. is 
it like DOS cmd line? And I am too confused in cammand_line_arguments like argc 
and pointer argv. I want to know about each and every thing about these, 
because of this i could not understand the below code and similar of it.There 
are 2 files below.Can anybody explain this code specially the main() function 
with its arguments?Pleaseeee........

My reply:

> the command line. is it like DOS cmd line?

Are you referring to bash? It is much better than Windows' cmd. DOS used 
command.com .

> There are 2 files below.Can anybody explain this code specially the main() 
> function with its arguments?

argv points to an array of pointers to strings. Try to printf ("%p %p\n", argv, 
argv[0]);

I decided to modify the code to be easier to understand. If you do not 
understand, ask what does a specific line.

# include 
# include 
# include 
# include 

int main(int argc,char *argv[])
{

FILE *in;
int count=0;
int ch;
what is the purpose of this IF_condition......
if(argc<2)
{
fprintf(stderr, "I %s require a filename.\n", argv[0]);
exit(1);
}

if((in=fopen(argv[1],"r"))== NULL)
{
fprintf (stderr, "%s : %s\n", argv[1], strerror(errno));
exit(2);
}

while ((ch=getc(in))!=EOF)
if(ch=='\n')
count++;

fclose(in);

printf("%d\n",count);
return 0;
}






____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and 
lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 



To unsubscribe, send a blank message to . 
Yahoo! Groups Links





       
---------------------------------
Pinpoint customers who are looking for what you sell. 

[Non-text portions of this message have been removed]

Reply via email to