Pointer to a Pointer to a struct
From: Rodrick Brown (rbrown[_at_)
Date: 10/15/04
- Previous message: Keith Thompson: "Re: get current path"
- Next in thread: Joona I Palaste: "Re: Pointer to a Pointer to a struct"
- Reply: Joona I Palaste: "Re: Pointer to a Pointer to a struct"
- Reply: Al Bowers: "Re: Pointer to a Pointer to a struct"
- Reply: Barry Schwarz: "Re: Pointer to a Pointer to a struct"
- Reply: John Bode: "Re: Pointer to a Pointer to a struct"
- Reply: aditya: "Re: Pointer to a Pointer to a struct"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 15 Oct 2004 07:07:40 GMT
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int
main(void)
{
typedef struct
{
char **test;
}Testing;
Testing **p;
p = malloc(sizeof(Testing));
p[0]->test[0] = malloc(sizeof(Testing));
strncpy(p[0]->test[0],"Hello World",20);
printf("%s\n",p[0]->test[0]);
return EXIT_SUCCESS;
}
Why does the following crash ?
Not sure what i'm missing please advise thanks.
-- Unix Systems Engineer The City of New York Dept. of Information Technology http://www.nyc.gov/doitt rbrown[(@)]doitt.nyc.gov http://www.rodrickbrown.com
- Previous message: Keith Thompson: "Re: get current path"
- Next in thread: Joona I Palaste: "Re: Pointer to a Pointer to a struct"
- Reply: Joona I Palaste: "Re: Pointer to a Pointer to a struct"
- Reply: Al Bowers: "Re: Pointer to a Pointer to a struct"
- Reply: Barry Schwarz: "Re: Pointer to a Pointer to a struct"
- Reply: John Bode: "Re: Pointer to a Pointer to a struct"
- Reply: aditya: "Re: Pointer to a Pointer to a struct"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|