im creating a program that reads in a csv fields and breaks it up into records and files using structures. my problem is that when i use the field constructor function with a char array it doesn't work, it prints out nothing:
Code:
RcrdArray[v].fieldArray[1] = Field_Constructor(0, 54, Field);
but when i use it like this it works, it prints out "any word":
Code:
RcrdArray[v].fieldArray[0] = Field_Constructor(0,54, "any word");
this is what the structures look like:
Code:
struct Rcrd Rcrd_Constructor(){
struct Rcrd record;
record.fieldArray;
record.rcrdDelimit = '\n';
return record;
}
struct Field Field_Constructor(int idx, int size, char *field){
struct Field fld;
fld.fldidx = idx;
fld.fldchrptr = field;
fld.fldsize = size;
fld.fldDelimit = ',';
return fld;
}
//this is the way i declared the array of pointers to Rcrd structs
struct Rcrd *RcrdArray
//this is the way i declared the field array
char Field[40] = {0};
I've spent a long time messing with this and changing things and i cant figure it out. I'm not very familiar with pointers and i have a feeling that it has something to do with that. Any help is appreciated. thanks.