Hello. This is my first post, and I am fairly new to C.
I am writing a socket program and I am getting a segmentation fault upon runtime. My program compiles fine. I'm pretty sure it is due to my implementation of my data structure.
My struct looks something like this:
typedef struct{
char* array;
}mystruct;
In main, can I assign a dynamic array like:
main(int argc,char *argv[]){
mystruct* A;
A->array = (char*) malloc(sizeof(argv[2])*sizeof(char));
}
Thank you for help!
M.