[LCP]passing struct to function
Tushar_Oza at Dell.com
Tushar_Oza at Dell.com
Sun Nov 21 09:53:01 UTC 2004
Shouldn't you be passing just list_ptr? Why the "ampersand" when making
the call??
-----Original Message-----
From: linuxcprogramming-admin at lists.linux.org.au
[mailto:linuxcprogramming-admin at lists.linux.org.au] On Behalf Of Carlos
Pruitt, Jr.
Sent: Saturday, November 20, 2004 5:36 PM
To: linuxcprogramming at lists.linux.org.au
Subject: [LCP]passing struct to function
I am trying to find what I am doing wrong. This program compiles with
the warning message:
warning: passing arg 1 of `print_mailing_list' from incompatible pointer
type
When I run the program, the output is:
f at carlos
#include <stdio.h>
#include <string.h>
struct mailing
{
char first_name[60];
};
void print_mailing_list(struct mailing *mlist) {
printf("%s\n", mlist->first_name); }
int main()
{
struct mailing list =
{
"carlos"
};
struct mailing *list_ptr;
if (strcmp(list.first_name, "carlos") == 0)
print_mailing_list(&list_ptr);
return 0;
}
--
Carlos E. Pruitt, Jr.
cept at bellsouth.net
Oliver's Law:
Experience is something
you don't get until just
after you need it.
_______________________________________________
This is the Linux C Programming List
: http://lists.linux.org.au/listinfo/linuxcprogramming List
More information about the linuxCprogramming
mailing list