Interested in the possibility of transferring an array of arrays of characters (strings) to a function with the ability to change the values of these strings globally.
#include <stdio.h> #include <string.h> void get(char ***s) { //пробовал еще (char **s[2]) *s[0] = "123"; return; } int main() { char *s[] = { "abc", "def" }; get(&s); printf("%s", s[0]); return 0; } Logically, everything should work - if we just pass the number a , then void get(int *a) , the array of characters get(char **s) , but with the array of strings it is no longer possible. How can I solve this problem?
void get(char *s[]) { s[0] = "123"; return; }void get(char *s[]) { s[0] = "123"; return; }void get(char *s[]) { s[0] = "123"; return; }, describe what you are actually creatingint main() { char *s[] = { "abc", "def" }; get(s); printf("%s", s[0]); return 0; }int main() { char *s[] = { "abc", "def" }; get(s); printf("%s", s[0]); return 0; }int main() { char *s[] = { "abc", "def" }; get(s); printf("%s", s[0]); return 0; }(note, replaced&sbysin theget()call) and everything will work (KISS principle) - avpvoid get(char ***s)does not match the type of the argument in theget(&s)call (forchar *s[] = {...};) - avp