-
array of structures
I can't figure out how to access data members in an array of structures to store data.
Here is my program:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct drivers_license
{
char lastname[10];
char firstname[10];
int licensenumber[8];
char statecode[2];
struct address;
int height;
char eyecolor[8];
char haircolor[8];
struct vehicle;
char visioncode[10];
int birthdate[3];
int expirationdate[3];
char organdonor[3];
};
struct address
{
int streetnumber[5];
char streetname[10];
int aptnumber[5];
char city[10];
char state[10];
int zipcode[5];
};
struct vehicle
{
char motorcycle;
char automobile;
char schoolbus;
char commericaltruck;
char semitrailer;
};
void records(struct drivers_license *record[15]);
void changes(struct drivers_license *record[15]);
int main()
{
struct drivers_license *record[15];
return 0;
}
void records(struct drivers_license *record[15])
{
record[0]->lastname[10]="Smith/0";
}
void changes(struct drivers_license *record[15])
{
}
when I compile it, it comes up with an error, saying cannot convert char * to char
-
struct mystruct myarray[3];
myarray[1].myvariable = 30;
> void records(struct drivers_license *record[15])
> {
> record[0]->lastname[10]="Smith/0";
> }
This is wrong. You cannot simply assign values like this. Additionally, you do not put a null in a string, it automaticly includes one.
Code:
void record( struct drivers_license record[] )
{
sprintf( record[0].lastname, "Smith" );
}
Quzah.