passing variable into a function

Hi

I am using GitHub - stevemarple/IniFile: Arduino library to parse ini files. library to create a config ini used at arduino start up.

If I call the function like below it works fine

if (ini.getValue("HSCOMMANDS", "command2", buffer, bufferLen)) {
   myStrings[2] =  buffer;
  }

it works fine. I have about 64 items to set in the array, So I would like to loop through the ini file and concatenate a variable and the loop counter and pass that to the function, however I am getting a

HttpRequestHomeSeerPost:140: error: no matching function for call to ‘IniFile::getValue(const char [11], String&, char [80], const size_t&)’ error

here is my code

 for (int j=0; j<=63; j=j+1) {
        String thisString = "command" ;
        String myJ = String(j) ;
        String mypass = thisString + myJ ;
        //Serial.print(mypass);

        if (ini.getValue("HSCOMMANDS", mypass, buffer, bufferLen)) {
        myStrings[j] = buffer;
        Serial.print(myStrings[j]);
        }
  }

how should I pass the variable mypass into the function???

thanks for all help
jasemilly

The best solution is to not use String for mypass. Instead use a null terminated char array (otherwise known as a string). I know it's confusing that String and string have such similar names but it's an important difference to understand. String seems to make things easier at first glance but in the end it's really not so hard to work with strings: https://www.arduino.cc/reference/en/language/variables/data-types/string/ http://www.cplusplus.com/reference/cstring/

My first piece of advice would be to use C style strings (zero terminated arrays of chars) instead of Strings. The latter have a reputation for fragmenting memory when manipulated within the program and whilst that is probably not the cause of your problem you would be wise to stop using them.