- #1
transgalactic
- 1,395
- 0
when i got a normal struct variable code:
but when my object is a part of an array and i take just one object
the same data input method doesn't work
why is that?
Code:
struct human {
char name[50];
int age;
float height;
};
struct human TR = {"Tony", 12, 1.5}; \\this works
but when my object is a part of an array and i take just one object
the same data input method doesn't work
why is that?
Code:
#include <stdio.h>
typedef struct robot ROBOT;
struct robot {
char *name;
int energy;
};
int main() {
int i;
ROBOT robots[3];
robots[0] = {"Lunar Lee", 50}; //this don't work