c - modify array element through pointer to a pointer -


i'm trying build program modifies element of array through pointer pointer. loaded debugger , see value of pointer changes, reason doesn't affect element in array. pointer syntax wrong? reassigning pointer somewhere else?

#include <stdio.h>  #include <stdlib.h>    #define size 6    /*   *    */      void change (char **x);    int main() {            char arra[] = "back";      char *c = arra;            change(&c);            int i;       printf("%c", arra[0]);      }               void change (char **x) {            *x = "h";        }

*x = "h"; 

should be

**x = 'h'; 

you trying modify first character , character has within single quotes.

there no need of pointer pointer here. can pass array decays pointer when passed in function parameterks shown @haccks


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -