Re: How to pass a struct to a function



Bill said:

<snip>

Here is what I have so far, won't even compile. And I am:

#include <stdio.h>
#include <string.h>

int AddEntry(struct entry);

struct{
char fName[51];
char lName[51];
char Phone[13];
}Entry;

You'll want to make this:

struct entry {
char fName[51];
char lName[51];
char Phone[13];
} Entry;

or, more clearly:

struct entry {
char fName[51];
char lName[51];
char Phone[13];
}; /* defines a type called 'struct entry' */

struct entry Entry; /* creates an object of that type */



--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.



Relevant Pages

  • [RFC] [Patch 4/4] timer_stats slimmed down: using statistics infrastucture
    ... (>80 char lines because of symbol names, ... * tstat entry structs only get allocated while collection is ... -static void reset_entries ... -static struct entry *alloc_entry ...
    (Linux-Kernel)
  • Re: what is the meaning of "char **option"?
    ... address of a location that holds the address of a location of a char. ... *option points to the first entry of the choices array, ... long as the entry is not NULL ... i compile it by GCC 4 on ArchLinux ...
    (comp.lang.c)
  • Re: why I cant input chars in the entryfield ?
    ... proc check_code {entry char} { ... Here my proc check_code is to insure the input is like "sz000063", ... checking is based on the current widget state (i.e. you aren't ... looking at what adding the new char does. ...
    (comp.lang.tcl)
  • Re: System.Text.RegularExpressions sintaxis
    ... it find any char & or % or | ... /// The main entry point for the application. ... [STAThread] ... static void Main ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Problem using schema.ini
    ... Each entry looks somewhat like this: ... Col2=Firstname Char Width 50 ... >I created a test filel with data, ... John Nurick [Microsoft Access MVP] ...
    (microsoft.public.access.externaldata)