Re: Passing an array of struct to function
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Tue, 18 Nov 2008 08:18:21 +0000
arnuld said:
I am passing an array of struct to a function to print its value. First
I am getting Segfaults and weired values. 2nd, is there any elegant way
to do this ?
/* Learning how to use an array of struct */
#include <stdio.h>
#include <stdlib.h>
enum { ARR_SIZE = 1 };
struct two_elem { char ch; char* word; };
void print_twoelem( struct two_elem*);
int main(void)
{
struct two_elem arr[ARR_SIZE];
If you're going to put two elements into this array, why do you define it
to have room for only one element?
The answer to your second question is "yes".
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.
- References:
- Passing an array of struct to function
- From: arnuld
- Passing an array of struct to function
- Prev by Date: Passing an array of struct to function
- Next by Date: Re: Passing an array of struct to function
- Previous by thread: Passing an array of struct to function
- Next by thread: Re: Passing an array of struct to function
- Index(es):
Relevant Pages
|