Changing an array with a function in C?

前端 未结 3 910
生来不讨喜
生来不讨喜 2020-12-03 00:12

I want to call a function and I want that function to change the contents of a string or array in the program to a constant.

Psuedocode:

some_array =         


        
3条回答
  •  孤城傲影
    2020-12-03 00:33

    You need to pass a pointer to array not the array itself.

    Another thing: add a control condition to your function. think: what will happen if "bingo" will be bigger than strlen(some_array) ? it will give you an error because in C you must malloc it if you need the array size to be dynamic !

提交回复
热议问题