larryfergy
Technical User
My input record consistes of a master record (the one that starts with the year) and the indented records that match. My idea was to load this into a structer so that I could later add other records that match to these master records.
1993 miniature Snowy Adventure 2 plate
Snowy Adventure mini plate by Donald Zolan$7.00 Bids 1
Snowy Adventure mini plate by Donald Zolan$7.00 Bids 1
1994 miniature Two of a Kind 1 plate
"Two of a Kind" mini plate by Donald Zolan $7.50 Bids 1
"Two of a Kind" mini plate by Donald Zolan $7.50 Bids 1
1991 miniature Morning Discovery 2 lithograph
Morning Discovery lithograph Donald Zolan $10.99 Bids 2
Morning Discovery lithograph Donald Zolan $10.99 Bids 2
The structer I developed was this
struct tagmom
{
int lineno;
char momsline[80];
struct tagdolan
{
int lineno;
char dolanline[80];
};
};
All the found records for the master record would be in that particular master record. Atleast that is what I thought
The build structer works;
#include <gc.h>
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include <time.h>
#include <string.h>
#include <conio.h>
FILE *in1;
FILE *in2;
FILE *in3;
FILE *out1;
char line[80];
char PLATE[15] = {
"PLATE"};
struct tagmom
{
int lineno;
char momsline[80];
struct tagdolan
{
int lineno;
char dolanline[80];
};
};
struct tagmom mymoms[100];
struct tagdolan mydolan[100];
char * Build_Structer(struct tagmom *m,struct tagdolan *d);
int
main(void)
{
char *cp;
char *ip;
char *op;
char *poldcloses;
char *result;
/* GC_malloc(sizeof(struct tagmom)*100);
; */
malloc(sizeof(struct tagmom)*100);
malloc(sizeof(struct tagdolan)*100);
struct tagmom *momsrecs;
momsrecs = mymoms;
struct tagdoln *dolanrecs;
dolanrecs = mydolan;
BuildStructer(momsrecs,dolanrecs);
fclose(in3);
fclose(out1);
return(0);
}
char *
BuildStructer(struct tagmom *mom,struct tagdolan *dolan)
{
char *poldrec;
char oldline[80];
int result;
int momline;
int doline;
char *pmom;
char *pdolan;
int nresult;
momline = 0;
doline = 0;
pmom = &mom;
in3 = fopen("c:\\lc\\datfiles\\zolan_finds\\oldcloses.txt", "r"
poldrec = fgets(restrict oldline,80,in3);
pmom = &mom;
doline = 0;
momline = 0;
/* mom->lineno = 0;
dolan->lineno = 0; */
do
{
do
{
poldrec = fgets(restrict oldline,80,in3);
nresult = isdigit(*poldrec);
}
while(*poldrec == '\n');
strcpy(mom[++momline].momsline,poldrec);
doline= 0;
do
{
poldrec = fgets(oldline,80,in3);
}
while(*poldrec == '\n');
do
{
strcpy(dolan[++doline].dolanline,oldline);
poldrec = fgets(oldline,80,in3);
if (poldrec == NULL)
break;
}
while(*poldrec != '\n');
}
while(poldrec != NULL);
mom->lineno = 1;
result = printf("\n%s",mom->momsline);
momline = 1;
doline = 1;
return (mom);
}
The build works. Or looks like it works. But when I reference the structer after the build with a debbugger or printing values have a problem
mom[1].momsline = 1993 miniature Snowy Adventure 2 plate
dolan[1].dolanline = Morning Discovery lithograph Donald Zolan $10.99 Bids 2
The master record is at 1
The found record is at last record
1993 miniature Snowy Adventure 2 plate
Snowy Adventure mini plate by Donald Zolan$7.00 Bids 1
Snowy Adventure mini plate by Donald Zolan$7.00 Bids 1
1994 miniature Two of a Kind 1 plate
"Two of a Kind" mini plate by Donald Zolan $7.50 Bids 1
"Two of a Kind" mini plate by Donald Zolan $7.50 Bids 1
1991 miniature Morning Discovery 2 lithograph
Morning Discovery lithograph Donald Zolan $10.99 Bids 2
Morning Discovery lithograph Donald Zolan $10.99 Bids 2
I also tried this structer
struct tagmom
{
int lineno;
char momsline[80];
char dolanline[100][80];
};
struct tagmom mymoms[100];
But the same thing happens . The build appears to work but the reference later doesn't
1993 miniature Snowy Adventure 2 plate
Snowy Adventure mini plate by Donald Zolan$7.00 Bids 1
Snowy Adventure mini plate by Donald Zolan$7.00 Bids 1
1994 miniature Two of a Kind 1 plate
"Two of a Kind" mini plate by Donald Zolan $7.50 Bids 1
"Two of a Kind" mini plate by Donald Zolan $7.50 Bids 1
1991 miniature Morning Discovery 2 lithograph
Morning Discovery lithograph Donald Zolan $10.99 Bids 2
Morning Discovery lithograph Donald Zolan $10.99 Bids 2
The structer I developed was this
struct tagmom
{
int lineno;
char momsline[80];
struct tagdolan
{
int lineno;
char dolanline[80];
};
};
All the found records for the master record would be in that particular master record. Atleast that is what I thought
The build structer works;
#include <gc.h>
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include <time.h>
#include <string.h>
#include <conio.h>
FILE *in1;
FILE *in2;
FILE *in3;
FILE *out1;
char line[80];
char PLATE[15] = {
"PLATE"};
struct tagmom
{
int lineno;
char momsline[80];
struct tagdolan
{
int lineno;
char dolanline[80];
};
};
struct tagmom mymoms[100];
struct tagdolan mydolan[100];
char * Build_Structer(struct tagmom *m,struct tagdolan *d);
int
main(void)
{
char *cp;
char *ip;
char *op;
char *poldcloses;
char *result;
/* GC_malloc(sizeof(struct tagmom)*100);
; */
malloc(sizeof(struct tagmom)*100);
malloc(sizeof(struct tagdolan)*100);
struct tagmom *momsrecs;
momsrecs = mymoms;
struct tagdoln *dolanrecs;
dolanrecs = mydolan;
BuildStructer(momsrecs,dolanrecs);
fclose(in3);
fclose(out1);
return(0);
}
char *
BuildStructer(struct tagmom *mom,struct tagdolan *dolan)
{
char *poldrec;
char oldline[80];
int result;
int momline;
int doline;
char *pmom;
char *pdolan;
int nresult;
momline = 0;
doline = 0;
pmom = &mom;
in3 = fopen("c:\\lc\\datfiles\\zolan_finds\\oldcloses.txt", "r"
poldrec = fgets(restrict oldline,80,in3);
pmom = &mom;
doline = 0;
momline = 0;
/* mom->lineno = 0;
dolan->lineno = 0; */
do
{
do
{
poldrec = fgets(restrict oldline,80,in3);
nresult = isdigit(*poldrec);
}
while(*poldrec == '\n');
strcpy(mom[++momline].momsline,poldrec);
doline= 0;
do
{
poldrec = fgets(oldline,80,in3);
}
while(*poldrec == '\n');
do
{
strcpy(dolan[++doline].dolanline,oldline);
poldrec = fgets(oldline,80,in3);
if (poldrec == NULL)
break;
}
while(*poldrec != '\n');
}
while(poldrec != NULL);
mom->lineno = 1;
result = printf("\n%s",mom->momsline);
momline = 1;
doline = 1;
return (mom);
}
The build works. Or looks like it works. But when I reference the structer after the build with a debbugger or printing values have a problem
mom[1].momsline = 1993 miniature Snowy Adventure 2 plate
dolan[1].dolanline = Morning Discovery lithograph Donald Zolan $10.99 Bids 2
The master record is at 1
The found record is at last record
1993 miniature Snowy Adventure 2 plate
Snowy Adventure mini plate by Donald Zolan$7.00 Bids 1
Snowy Adventure mini plate by Donald Zolan$7.00 Bids 1
1994 miniature Two of a Kind 1 plate
"Two of a Kind" mini plate by Donald Zolan $7.50 Bids 1
"Two of a Kind" mini plate by Donald Zolan $7.50 Bids 1
1991 miniature Morning Discovery 2 lithograph
Morning Discovery lithograph Donald Zolan $10.99 Bids 2
Morning Discovery lithograph Donald Zolan $10.99 Bids 2
I also tried this structer
struct tagmom
{
int lineno;
char momsline[80];
char dolanline[100][80];
};
struct tagmom mymoms[100];
But the same thing happens . The build appears to work but the reference later doesn't