-
errors on structures
void records(struct drivers_license *record[15]);
void changes(struct drivers_license *record[15]);
int main()
{
struct drivers_license record[15];
sprintf(record[0].lastname,"Daniel");
printf("%12s",record[0].lastname);
records(*record[]);//expression syntax error right here
changes(*record[]);//expression syntax error right here
return 0;
}
void records(struct drivers_license *record[15])
{
printf("%s",record[0]->lastname);
}
void changes(struct drivers_license *record[15])
{
}
I get an expression syntax error in main when trying do declear the records and changes functions.
-
I had to recreate the structure to keep from getting a slew of errors, but the two errors you got can be eliminated by just passing the array name, without the dereference operator and [] operators. Like so:
Code:
#include <stdio.h>
void records(struct drivers_license record[15]);
void changes(struct drivers_license record[15]);
struct drivers_license{
char lastname[1024];
};
int main(void){
struct drivers_license record[15];
sprintf(record[0].lastname,"Daniel");
printf("%12s",record[0].lastname);
records(record); /*array name only*/
changes(record); /*array name only*/
return 0;
}
void records(struct drivers_license record[15]){
printf("%s",record[0].lastname); /*no pointer, no ->*/
}
void changes(struct drivers_license record[15]){
/*placeholder*/
}