pointers - why dosn't this work?
    Aryeh M. Weiss 
    aryeh at eddie.mit.edu
       
    Thu Apr  5 10:50:44 AEST 1990
    
    
  
In article <23467 at mimsy.umd.edu> dbk at mimsy.umd.edu (Dan Kozak) writes:
>From article <6067 at ozdaltx.UUCP>, by root at ozdaltx.UUCP (root):
>> This is driving me crazy!  According to the C books, this should work,
>> but yet I get core dumps when I compile and run it.  Suggestions???
>
>Sell that book.
>
>> #include <stdio.h>
>> #include <string.h>
>> main()
>> {
>>       char b[1][20];
>>       char *x="This is a test";
>>       char *a[3];
>	     ^^^^^ this is a pointer to an array of 3 chars, but the
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No way, Jose', this is an array of 3 pointers of type char.
(A pointer to an array is just a pointer.)
>		   array(s) that it points to have not been allocated
>		   and it hasn't itself been initialized.
>	
>Clever:         dbk at mimsy.umd.edu | "For I was rolled in water,
>Not-so-clever:  uunet!mimsy!dbk   |  I was rolled out past the pier" - MoB
-------------
``I must go.  Somewhere a bug is happening.''
-- 
    
    
More information about the Comp.unix.xenix
mailing list