--- In [email protected], "Ahmed Shabana" <[EMAIL PROTECTED]> wrote:
>
> On 7/15/07, Nico Heinze <[EMAIL PROTECTED]> wrote:
> > --- In [email protected],
> >  > "Ahmed Shabana" <UnlimitedEng@> wrote:
> >  >
> >  > when I try this code :
> >  >
> >  > #include<stdio.h>
> >  > main ()
> >  > {
> >  >         char *name[] = { "ligal month","jan","fed" };
> >  >         printf( "%s\n" , *++name[1] );
> 
> >  > }
> >  >
> 
> and in this compilation has no errors
> but when I execute the code this message appears
> segmentation fault
> >
> >  Because "name" is the name of an array. It is NOT a pointer.
> >  Why do you want to increment "name" here at all?
> >
> >  To make it somewhat clearer: although in terms of
> > indexing the name of an array can be intermixed with
> > a pointer to its first element, the name of an array
> > is still a name and hence something "constant" to the
> > compiler; on the other hand a pointer can be changed
> > (except if declared "const ...*..."). Still these two
> > are different entities for the language specifications.
> >
> I saw the same code in the BASH command line programs but
> instead of name it was argv and it has the same syntax
> ???????????

The Bash is a shell; we are talking about C programming here.
These are completely different concepts. Please keep in mind that a
shell is _written_ in C, but it implements its own language.

To make it clearer: every application is free to implement its own
standards, for example its own syntax and so on. But if you want to
learn C, then learn C and not the Bash; these are two completely
different systems.

Regards,
Nico

Reply via email to