J
jesse
alo. i'm learning c at the moment, and i'm attempting to make little
experiments with struct types. here's my code:
#include <stdio.h>
struct bin {
char name[30];
int quantity;
float cost;
};
int main()
{
struct bin cablebin;
cablebin.name = "Printer Cables";
cablebin.quantity = 25;
cablebin.cost = 11.95;
printf("A bin of %d %s at $%f a piece will cost $%f.\n",
cablebin.quantity, cablebin.name, cablebin.cost,
cablebin.cost*cablebin.quantity);
return 0;
}
for some reason, i get the following error:
Error E2277 struct.c 13: Lvalue required in function main
line 13 is: cablebin.name = "Printer Cables";
i'm a bit confused; my code should be correct, so i don't know what's going.
jesse.
experiments with struct types. here's my code:
#include <stdio.h>
struct bin {
char name[30];
int quantity;
float cost;
};
int main()
{
struct bin cablebin;
cablebin.name = "Printer Cables";
cablebin.quantity = 25;
cablebin.cost = 11.95;
printf("A bin of %d %s at $%f a piece will cost $%f.\n",
cablebin.quantity, cablebin.name, cablebin.cost,
cablebin.cost*cablebin.quantity);
return 0;
}
for some reason, i get the following error:
Error E2277 struct.c 13: Lvalue required in function main
line 13 is: cablebin.name = "Printer Cables";
i'm a bit confused; my code should be correct, so i don't know what's going.
jesse.