Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a beginners question...about struct 1

Status
Not open for further replies.

hoggle

Programmer
Jul 13, 2001
124
US
I keep getting this error when I try to compile, the program is an assignment so the way it's being done isn't the smartest (I'd use classes but my professor wants is to be done using structs) here's the code and the error if anybody can see what is wrong...because I can't thanks.

the error:c:\windows\desktop\person2\person.c(8) : error C2059: syntax error : 'PCH creation point'

also a warning:c:\windows\desktop\person2\person.c(46) : warning C4013: 'fill' undefined; assuming extern returning int
Error executing cl.exe.


here's the code:
#include <stdio.h>
#include <stdlib.h>
#include &quot;person.h&quot;


void fill(struct person* P)
{
printf(&quot;Please enter the name: &quot;);
scanf(&quot;%s&quot;, &P->First);

printf(&quot;Please enter the last name: &quot;);
scanf(&quot;%s&quot;, &P->Last);

printf(&quot;Please enter the address: &quot;);
getchar();
gets(P->Address);

printf(&quot;Please enter the city: &quot;);
scanf(&quot;%s&quot;, &P->City);

printf(&quot;Please enter the state: &quot;);
scanf(&quot;%s&quot;, &P->State);

printf(&quot;Please enter the zip: &quot;);
scanf(&quot;%s&quot;, &P->Zip);

}
void display(struct person P)
{
printf(&quot;%s\n&quot;, P.First);
printf(&quot;%s\n&quot;, P.Last);
printf(&quot;%s\n&quot;, P.Address);
printf(&quot;%s\n&quot;, P.City);
printf(&quot;%s\n&quot;, P.State);
printf(&quot;%s\n&quot;, P.Zip);
}

int main(void)

{

struct person P;

fill(&P);

display(P);

exit (1);
}

and here's the code for person.h
/* structure for person program */

#define NSIZE 20 /* Maximum name length */
#define ASIZE 30 /* maximum address lenght */
#define CSIZE 25 /* maximum city & state length */
#define ZSIZE 10 /* maximum zip code length */

struct person
{
char First[NSIZE];
char Last[NSIZE];
char Address[ASIZE];
char City[CSIZE];
char State[CSIZE];
char Zip[ZSIZE];
}
 
Hoggle,
As per MSDN, Error 2059:&quot;Depending on the code, this error may result from a failure to include a line continuation character in a multi-line #define or macro definition statement, or from placing an integer constant on a line by itself. &quot;

You may move the #defines to the top of the program and see if it compiles differently
-shreik26
 
try to:
1. take away he struct keyword from both functions declarations
2. rebuild the entire project s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darkness...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top