IF condition is a test for the number of command line arguments if it's 2
arguments only, the if body (usrfail function) is fired .
BTW i added you to yahoo messenger for any next questions.
Thanks in advance
On 7/9/07, asma sabir <[EMAIL PROTECTED]> wrote:
>
> Thanks Mina
> can u explain, what's the purpose of 2 IF_conditions in the main()
> function of FILE2.
>
> thanks in advance
> asma.
>
> Mina Ramses <[EMAIL PROTECTED] <mina.ramses%40gmail.com>> wrote:
> there is what's called command line arguments and they have also like a
> counter , Argv is the variable itself and the Argc is the counter , read
> some more about Linux programming .
> And any help if you have some trouble.
>
> On 7/9/07, asma sabir <[EMAIL PROTECTED] <bcsf04a077%40yahoo.com>>
> wrote:
> >
> > Hi to everyone;
> > I know just little about C and that was also learnt by reading book for
> > beginners i.e. "how to program in C" and also after joined your group
> that
> > was really helpful for beginners. 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.Cananybody explain this code specially the main() function with its
> > arguments?Pleaseeee........
> > Thanksssssss in Advance.
> > asma.
> > __________________________________________________________
> > file1.c
> > # include "glob.h"
> >
> > void sysfail(int rc,char *message)
> > {
> >
> > perror(message);
> > exit(rc);
> > }
> >
> > void usrfail(int rc,char *message)
> > {
> >
> > fprintf(stderr,message);
> > exit(rc);
> > }
> >
> > __________________________________________________________
> >
> > file2.c
> > # include "glob.h"
> >
> > int main(int argc,char *argv[])
> > {
> >
> > FILE *in;
> > int count=0;
> > int ch;
> >
> > if(argc<2)
> > usrfail(1,"Command requires a filename");
> >
> > if((in=fopen(argv[1],"r"))== NULL)
> > sysfail(2,argv[1]);
> >
> > whlie ((ch=getc(in))!=EOF)
> > if(ch=='\n')
> > count++;
> > fclose(in);
> >
> > printf("%d\n",count);
> > return (0);
> > }
> >
> >
> > ---------------------------------
> > Park yourself in front of a world of choices in alternative vehicles.
> > Visit the Yahoo! Auto Green Center.
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
>
> --
> |Mina r. Fahmy|
> ----------------------------------------------------------
> GNU/Linux registered user #312544 * Debian 3.1 Sarge * PC
> http://mina-fahmy.blogspot.com
> Linux Network Consultant member
> ===============================================================
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.5 (GNU/Linux)
>
> iD8DBQFDjwHQS45JQJZP7ZQRAmUDAJ9Q8cUGdii55uGM2uQJj7ICUqGTwACgm78g
> rYYpiMdrJW0XS+Xou15bREE=
> =m1Lp
> -----END PGP SIGNATURE-----
>
> =============
> Key ID: 0x964F ED94 on --keyserver http://wwwkeys.eu.pgp.net
> Key fingerprint = 35DD 3279 EB3E A711 1205 466F 4B8E 4940 964F ED94
> ===============================================================
>
> [Non-text portions of this message have been removed]
>
> ---------------------------------
> Be a PS3 game guru.
> Get your game face on with the latest PS3 news and previews at Yahoo!
> Games.
>
> ---------------------------------
> Boardwalk for $500? In 2007? Ha!
> Play Monopoly Here and Now (it's updated for today's economy) at Yahoo!
> Games.
>
> [Non-text portions of this message have been removed]
>
>
>
--
|Mina r. Fahmy|
------------------------------------------------------------------------------------------
GNU/Linux registered user #312544 * Debian 3.1 Sarge * PC
http://mina-fahmy.blogspot.com
Linux Network Consultant member
===============================================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
iD8DBQFDjwHQS45JQJZP7ZQRAmUDAJ9Q8cUGdii55uGM2uQJj7ICUqGTwACgm78g
rYYpiMdrJW0XS+Xou15bREE=
=m1Lp
-----END PGP SIGNATURE-----
=============
Key ID: 0x964F ED94 on --keyserver http://wwwkeys.eu.pgp.net
Key fingerprint = 35DD 3279 EB3E A711 1205 466F 4B8E 4940 964F ED94
===============================================================
[Non-text portions of this message have been removed]