0

I have a 2D char array and I want to change all the occurrences of a particular element. For an example, I want to change all occurrences of "ant" to "dummy" without using structs. Input {"hello", "ant", "bird", "ant", "ant"} Output {"hello", "dummy", "bird", "dummy", "dummy"}

I want to implement this in C language and my code is shown below.line is the 2D array with words.

 for(int m = 0; m< tot; m++){
                if (!strcmp(line[m],"ant")){
                        printf("hit\n");
                        line[m]="dummy";
                    }
}

I am getting an error assignment to expression with array type.

python_coder_
  • 103
  • 1
  • 1
  • 6

0 Answers0