My code is as follows:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct{
char ID[1];
char Content[4];
}
int main(){
DATA z[1];
DATA t;
int c1, c2;
scanf("%c",z[1].ID);
scanf("%s",z[1].Content);
printf("\n");
c1=strlen(z[1].ID);
c2=strlen(z[1].Content);
t=z[1];
printf("t:\n");
printf("%s\n",t.ID);
printf("%s\n",t.Content);
printf("\n");
printf("z:\n");
printf("%s\n",z[1].ID);
printf("%s\n",z[1].Content);
printf("\n");
printf("Length of z's ID: %d.\n",c1);
printf("Length of z's Content: %d.\n",c2);
}
And this is what I get when executing it:
8
3092
t:
83092
3092
z:
83092
3092
Length of z's ID: 5.
Length of z's Content: 4.
I don't know why the ID has more than 1 element when it should only have 1. Please help, because I need to fix this for a project I'm working on. Thanks.