I have a struct that is named item
, now I have another struct that is called array
that calls item
. The struct item arrayofList
is required to be of the size 5
#include <stdio.h>
#include <string.h>
#define MaxItems 5
#define NameLength 20
#define UnitLenght 6
struct item
{
char name[NameLength];
float amount;
char unit[UnitLenght];
};
struct array
{
struct item arrayofList;
};
int main(void)
{
struct array shopping[MaxItems];
Am I giving the list size of 5 or am I doing it incorrectly
You probably want this:
#include <stdio.h>
#include <string.h>
#define MaxItems 5
#define NameLength 20
#define UnitLenght 6
struct item // one item
{
char name[NameLength];
float amount;
char unit[UnitLenght];
};
int main(void)
{
struct item shopping[MaxItems]; // array of MaxItems struct items
...
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments