c++ - Passing the char *str inside the function -


i newly started c++ , feels pretty wired while writing java while. so, have array,

char values[][10] = {"miami", "seattle", "berlin"};  int rows = sizeof values / sizeof values[0]; 

this function pass value,

// function reverse strings  void app::reverse(char *str) {  } 

when loop, can't apparently pass value there,

   (int = 0; < rows; ++i) {           // first character of string          char *firstptr = values[i];         reverse(firstptr);     } 

the line reverse(firstptr) provides error don't understand. error message says too few arguments, expected 2.

what issue here? apologize mistakes writing c++ first time , pointer stuff feels strange.

update

this piece of code exexute,

void app::reverse(char* str) {      // first character of string      char *ptrend = str;     char temp;      if (str){          while (*ptrend) {             ptrend++;         }          ptrend--;          // long first adddress lesser end          while (str < ptrend) {              temp = *str;             *str++ = *ptrend;                         *ptrend-- = temp;         }     } } 

there little information here sure, looks have

using namespace std; 

somewhere in code. don't this! in case, standard library has function reverse() in std takes 2 parameters.

furthermore, have void app::reverse(char *str), cannot seen void myarray::reverse(char* str), own reverse() cannot called as-is - need app::reverse() if function class static.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -