i'm attempting to use pointers to pass an array of string to and back from a function, or more specifically initializing an array of strings in the main function and using another function to define said array. The issue being that I'm using a for loop to assign a string to an array index, and when the index is larger than 20, (and in turn the for loop) it stops responding. It works fine when its less than or equal to 20.
#include <string.h>
#include <stdlib.h>
#define MAX 21
#define MAXA MAX+1
#define SIZEAR 6
void col(int *pgv,char **sizev,int *coffv,int *moffv,int *yoffv) {
for (int i=0;i<MAX;i++) {
int m=i%2;
//Size
if (m==0)
strcpy(sizev[i],"Small");
else
strcpy(sizev[i],"Large");
}
}
int main(void) {
int i,pg[MAXA],coff[MAXA],moff[MAXA],yoff[MAXA];//seen
char **size = (char**)malloc(MAXA*sizeof(char*));
for(i=0;i<MAXA;i++)
size[i]=(char*)malloc(SIZEAR*sizeof(char));
col(pg,size,coff,moff,yoff);
return 0;
}