I have set a structure type:
typedef struct {
char *snt[MAX_LINE_LENGTH];
} sentence;
And this line is getting a cast specifies array type error:
sentence copySentence(sentence *source) {
sentence nw;
nw.snt = (char *[])source->snt; //Here is the error
return nw;
}
What is the best fix for this code line and what is the problem?
char *sentence[MAX_LINE_LENGTH];tochar **sentence;andmallocit according toMAX_LINE_LENGTH. Then you'll not need to cast anything.nw = *source;instead of that line. Or replace the whole function withreturn *source;. This will do a shallow copy. If you want a 'deep copy' then you need to explain more about how you allocate memory for your sentences.MAX_LINE_LENGTHis a strange name for the count of how many lines you have.