This is my code:
#include <stdio.h>
#include "addStruct.h"
/*This is the addStruct class:
struct addStruct
{
char name[50];
char address[50];
int zipcode;
}
*/
#include <stdlib.h>
void main()
{
struct addStruct * address[3];
int j = 0;
while(1 != 0)
{
address[j] = (struct addStruct*)malloc(sizeof(struct addStruct));
printf("What name belongs to the address? ");
fgets(address[j]->name, 50, stdin);
printf("What address are you adding? ");
fgets(address[j]->address, 50, stdin);
printf("What zipcode is the address in? ");
scanf(" %d", &address[j]->zipcode);
j++;
getchar();
printf("Do you want to continue adding addresses? (Y/N) ");
char input;
input = getchar();
if(input == 'n' || input == 'N')
{
break;
}
getchar();
}
for(int i = 0; i < j; i++)
{
getchar();
printf("Name %d: %s", i+1, address[i]->name);
printf("Address %d: %s", i+1, address[i]->address);
printf("Zipcode %d: %d", i+1, address[i]->zipcode);
}
return;
}
These are my errors:
/usr/lib/gcc/x86_64-linux-gnu/11/include/stddef.h:321:9: error: expected ‘;’, identifier or ‘(’ before ‘int’
321 | typedef __WCHAR_TYPE__ wchar_t;
| ^~~~~~~~~~~~~~
In file included from main.c:11:
/usr/include/stdlib.h:933:20: error: expected declaration specifiers or ‘...’ before ‘wchar_t’
933 | extern int mbtowc (wchar_t *__restrict __pwc,
| ^~~~~~~
/usr/include/stdlib.h:937:31: error: expected declaration specifiers or ‘...’ before ‘wchar_t’
937 | extern int wctomb (char *__s, wchar_t __wchar) __THROW;
| ^~~~~~~
/usr/include/stdlib.h:941:25: error: expected declaration specifiers or ‘...’ before ‘wchar_t’
941 | extern size_t mbstowcs (wchar_t *__restrict __pwcs,
| ^~~~~~~
/usr/include/stdlib.h:946:39: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
946 | const wchar_t *__restrict __pwcs, size_t __n)
| ^
I have no idea why it doesn't work, any explanation would be superb. Thanks in advance