First of all, this is a test program, i wanna test something specific that i wanted to see if it works. Lets say that i wanna assign x to arr[0][4] and wanna keep this change so that arr[0][4] is x in the main function too:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void changE(char *arr[10][5]);
int main(void){
char *arr[10][5];
arr[0][0] = "Johny";
arr[0][1] = "Tony";
arr[0][2] = "Tiki";
arr[0][3] = "Kitty";
arr[0][4] = "Douglas";
arr[1][0] = "Piki";
arr[1][1] = "Kati";
arr[1][2] = "Sathi";
arr[1][3] = "Dony";
changE(arr);
int i = 0;
int j;
for(i;i<=1;i++){
for(j=0;j<=4;j++){
printf("%s\n", arr[i][j]);
}
printf("\n\n\n");
}
return 0;
}
void changE(char *arr[10][5]){
char x[50] = "Tinky";
arr[0][4] = x;
}
The problem is that i cant assign x to arr[0][4], the program just shuts down. I also tried strcpy, this:
void changE(char *arr[10][5]){
char x[50] = "Tinky";
strcpy(arr[0][4], x);
}
Its the same thing with strcpy the program just shuts down. I can only do this:
void changE(char *arr[10][5]){
arr[0][4] = "Tinky";
}
Which doesnt help me at all, considering that x is a string that i dont know(or a string from scanf). So if x comes from a scanf how can i assign x to arr[0][4]? Any help would be appreciated! Thanks :)