I kept getting the error "Command terminated by signal 11" when I try to save a string into an array of strings. After changing the code from the link below, now the name prints out ���W.
I used this link to fix my code off of but it is still causing me to get the error "Command terminated by signal 11".
#include<stdio.h>
#include<string.h>
void getName(char* c[], int size);
int main(void) {
int yenoSize = 0;
int strSize = 0;
char name1[30];
char* name[30];
char* students[5][30];
for(int i=0;i<1;i++){
getName(name, strSize);
students[i][0] = name1;
}
for(int k=0; k<1;k++){
printf("Student Name: %s \n", students[k][30]);
}
}
void getName(char* c[], int size){
char name1[30];
printf("Enter student name: ");
fgets(name1, 30, stdin);
c[0] = &name1[0];
printf("%s", name1);
}
The output is supposed to print out the name that the user inputs (Student Name: Jon) but it is currently printing ���W. How can I fix the problem? I believe the problem exists with the name pointer pointing to null. Is that the problem? I appreciate the help!