Getting a buffer overflow when compiling this code. Can anyone spot the issue? No error at all when compiled in Windows terminal but the strings refuse to print. Tried changing to subscript notation but compiler just throwing loads of errors.
#include <stdio.h>
#include <string.h>
// #define's
#define PEOPLE 3
#define LINES 4
#define NAMELENGTH 30
#define ARRAYSIZE 24
// structure templates
struct certs
{
int
employee_ID1,
employee_ID2,
employee_ID3,
employee_ID4,
employee_ID5,
employee_ID6;
char
*certificate1,
*certificate2,
*certificate3,
*certificate4,
*certificate5,
*certificate6;
};
struct details
{
char *firstName1[NAMELENGTH],
*firstName2[NAMELENGTH],
*firstName3[NAMELENGTH],
*firstName4[NAMELENGTH],
*firstName5[NAMELENGTH],
*firstName6[NAMELENGTH];
char *surName1[NAMELENGTH],
*surName2[NAMELENGTH],
*surName3[NAMELENGTH],
*surName4[NAMELENGTH],
*surName5[NAMELENGTH],
*surName6[NAMELENGTH];
struct certs ID_cert;
};
struct line
{
struct details line1;
struct details line2;
struct details line3;
struct details line4;
};
int main()
{
int i, j;
struct line lineDetails;
removed the other strcpy's for the purposes of the question.
// SurNames (Team 4)
strcpy(lineDetails.line4.surName1[NAMELENGTH], "powers");
strcpy(lineDetails.line4.surName2[NAMELENGTH], "garcia");
strcpy(lineDetails.line4.surName3[NAMELENGTH], "smith");
strcpy(lineDetails.line4.surName4[NAMELENGTH], "woods");
strcpy(lineDetails.line4.surName5[NAMELENGTH], "wick");
strcpy(lineDetails.line4.surName6[NAMELENGTH], "collins");
printf("\n%s",lineDetails.line4.surName2);
}