Mail Archives: djgpp/2001/05/25/23:00:05
From: | "W. Gwinn" <Lithiemgod AT hotmail DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Problem w/Scanf
|
Lines: | 59
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.00.2615.200
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2615.200
|
Message-ID: | <fREP6.6639$xM2.2800101@typhoon2.ba-dsg.net>
|
Date: | Sat, 26 May 2001 02:49:47 GMT
|
NNTP-Posting-Host: | 151.204.73.2
|
X-Complaints-To: | business-support AT verizon DOT com
|
X-Trace: | typhoon2.ba-dsg.net 990845387 151.204.73.2 (Fri, 25 May 2001 22:49:47 EDT)
|
NNTP-Posting-Date: | Fri, 25 May 2001 22:49:47 EDT
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
When i compile and run this code i have the following problem:
the printprop line at the end of editprop function will show what is typed
at the scanf("%s%,prop.name); line.
All the other lines though, will not change. the data in the ints stays the
same as before the function runs.
if, however, one does
prop.purccost=**any number not purccost** , then it will show in the
printprop, so i know that the data is passing prperly to the print function.
it behaves the same whether i use %i %hi %hd or %d in the scanf line
Any help would be greatly appreiciated.
Thank you
struct propertydata
{
char name[30];
int purccost,houscost,group,improvement,recnum,ownedby;
bool mortgaged;
int rent[6];
}
void printprop(propertydata prop)
{
printf("\n\nName of Property:\t\t\t%s\nRent (no house): \t\t\t%i\nRent (1
house): \t\t\t%i\nRent (2 houses): \t\t\t%i\nRent (3 houses): \t\t\t%i\nRent
(4 houses): \t\t\t%i\nRent (Hotel): \t\t\t\t%i\nCost of house:
\t\t\t%i\nCost of
property:\t\t\t%i\n",prop.name,prop.rent[0],prop.rent[1],prop.rent[2],prop.r
ent[3],prop.rent[4],prop.rent[5],prop.houscost,prop.purccost);
};
void editprop(propertydata &prop)
{
printf("\n\t\tRecord #%i.",prop.recnum);
printf("\nName: \t %s\t",prop.name);
scanf("%s",prop.name);
printf("\nCost \t%i\t",prop.purccost);
scanf("%d",prop.purccost);
printf("\nHouse Cost\t%i\t",prop.houscost);
scanf("%d",prop.houscost);
printf("\nColor Group\t%i\t",prop.group);
scanf("%d",prop.group);
printf("\nRents:\nNo Houses:\t%i\t",prop.rent[0]);
scanf("%d",prop.rent[0]);
printf("\n1 Houses:\t%i\t",prop.rent[1]);
scanf("%d",prop.rent[1]);
printf("\n2 Houses:\t%i\t",prop.rent[2]);
scanf("%d",prop.rent[2]);
printf("\n3 Houses:\t%i\t",prop.rent[3]);
scanf("%d",prop.rent[3]);
printf("\n4 Houses:\t%i\t",prop.rent[4]);
scanf("%d",prop.rent[4]);
printf("\nHotel :\t%i\t",prop.rent[5]);
scanf("%d",prop.rent[5]);
printprop(prop);
};
- Raw text -