incompatible types in assignment of 'char*' to 'char [20]'

I am trying to avoid using strings in several functions, namely this one after I have noticed unstable operation. The problem is I can’t seem to get char* and char[20] to line up.

I get incompatible types in assignment of ‘char*’ to ‘char [20]’

See lcdOut0 and 1. If I were to set them to char*, I get null output at the bottom of the function. If I declare em as char[20], I get an the error. Can padRight() be a char[20]? I tried and that didn’t work either.

void menuM() { // Have a timeout for menu display to revert back to normal display
char lcdOut0[20] = { 0 };
char lcdOut1[20] = { 0 };
// char* lcdOut0, lcdOut1;
  char outText[20] = { 0 };
  char currentHHchar[3] = { 0 };
  char currentMMchar[3] = { 0 };
  char buf;
  char mainM[6][20] = { "Time Settings", "Schedule", "Fan Settings", "Lock Settings", "Temp. Settings" };
  char timeM[6][20] = { {"Time Set"}, {"Auto/NTP Time Set"}, {"Temp Timeout"}, {"Fan Timeout."}, {'.'} };
  char scheduleM[6][20] =  { {"Set # of blocks"}, {"Select Block"}, {"Set block time"}, {"Set block Temp"}, {'.'} };
  char fanM[6][20] = { {"On with H/C"}, {"On all time"}, {"Post-mix..."}, {"On Every..."}, {'.'} };
  char lockM[6][20] = { { "Lock?" }, {"Lock Timeout"}, {"."}, {"."} , {'.'}  };
  char tempM[6][20] = { {"Hysteresis"}, {"Temp. Alerts"}, {"."}, {'.'}, {'.'} };
  int menuItem = menuAddress();
  int MM2, HH2;
  Serial.print(menuDepth);
  //Serial.print(menuIDa);
  //Serial.print(menuIDb);
  //Serial.println(menuIDc);
  Serial.println(menuItem);

  if (menuIndex < 0) menuIndex = 4;   //Keep from running outside array bounds
  if (menuIndex > 4) menuIndex = 0;   //Keep from running outside array bounds
  if (cursorPosition > 2) cursorPosition = 0; //Wrap cursor at 2
  if (cursorPosition < 0) cursorPosition = 2; //Wrap cursor at 2

  if (menuDepth == 0) { //Main Menu
        memcpy(mainM[menuIndex], lcdOut1, 20);
        memcpy(mainM[menuIndex + 1], lcdOut1, 20);
    goto endPoint;
  }
  if (menuDepth == 1) { // Sub-menus
    switch (menuIDa) {
      case 0: //Time Menu
        memcpy(timeM[menuIndex], lcdOut1, 20);
        memcpy(timeM[menuIndex + 1], lcdOut1, 20);
        break;
      case 1: //Schedule Menu
        memcpy(scheduleM[menuIndex], lcdOut1, 20);
        memcpy(scheduleM[menuIndex + 1], lcdOut1, 20);
        break;
      case 2: //Fan Menu
        memcpy(fanM[menuIndex], lcdOut1, 20);
        memcpy(fanM[menuIndex + 1], lcdOut1, 20);
        break;
      case 3: //Lock Menu
        memcpy(lockM[menuIndex], lcdOut1, 20);
        memcpy(lockM[menuIndex + 1], lcdOut1, 20);
        break;
      case 4: //Temperature Menu
        memcpy(tempM[menuIndex], lcdOut1, 20);
        memcpy(tempM[menuIndex + 1], lcdOut1, 20);
        break;
    }
  }

  Serial.println(menuIDb);
  if (menuDepth == 2) {
    if (menuIDa == 0) { //time menu
      switch (menuIDb) {
        case 0: //Set time
          //polls current time and displays it like "*22* : 34" with stars around which to change
          //An up cursor will increment hour
          //A left cursor will select minutes to change
          lcdOut0 = padRight("Set time.",20);
          HHOffset = readEEprom("HHOffset");
          MMOffset = readEEprom("MMOffset");
          HH2 = currentHH + HHOffset;
          MM2 = currentMM + MMOffset;

          itoa(HH2, currentHHchar, 10);
          itoa(MM2, currentMMchar, 10);

          if (cursorPosition == 0) lcdOut1 = padRight(strcat(strcat("*", currentHHchar), strcat("*:", currentMMchar)),20);
          if (cursorPosition > 0) lcdOut1 = padRight(strcat(strcat(currentHHchar, ":*"), strcat(currentMMchar, '*')),20);
          break;
        case 1: //Auto/NTP Timeset
          lcdOut0 = "Auto/NTP Timeset";
          if (readEEprom("timeNTP") == 0) {
            lcdOut1 = "On / *OFF*";
          }
          else {
            lcdOut1 = "*ON* / Off";
          }
          //Select/left will change state of ntpOn
          break;
        case 2: //Temperature & Fan Change timeouts
          lcdOut0 = "Temp Timeout Mins";
          lcdOut1 = readEEprom("tempTimeout");
          break;
        case 3: // Fan Timeout
          lcdOut0 = "Fan Timeout Mins";
          lcdOut1 = readEEprom("fanTimeout");
      }
    }
    if (menuIDa == 1) { // Schedule Menu
      switch (menuIDb) {
        case 0:
          lcdOut0 = "# of blocks 2-8";
          lcdOut1 = readEEprom("timeBlocks");
          break;
        case 1:
          lcdOut0 = "Select Block";
          lcdOut1 = currentBlock;
          break;
        case 2:
          lcdOut0 = rightPad(strcat("Set time for ", currentBlock);,20)


          strcat(strcat(scheduleArray(currentBlock, 'r', "timeHH", 0), ";*"), strcat(scheduleArray(currentBlock, 'r', "timeMM", 0), '*'));
          if (cursorPosition == 0) lcdOut1 =  rightPad(strcat(strcat('*', scheduleArray(currentBlock, 'r', "timeHH", 0)), strcat("*:", scheduleArray(currentBlock, 'r', "timeMM", 0))));
          if (cursorPosition > 0) lcdOut1 = rightPad(strcat(strcat(scheduleArray(currentBlock, 'r', "timeHH", 0), ";*"), strcat(scheduleArray(currentBlock, 'r', "timeMM", 0), '*')));
          break;
        case 3:
          lcdOut0 = rightPad(strcat("Set Temp. for ", currentBlock));
          lcdOut1 = scheduleArray(currentBlock, 'r', "temp", 0);
          break;
      }
    }
    if (menuIDa == 3) { //Lock Menu
      switch (menuIDb) {
        case 0:
          lcdOut0 = "Lock status";
          if (readEEprom("lock") == 0) lcdOut1 = "*ON* / off";
          else  lcdOut1 = "on / *OFF*";
          break;
        case 1:
          break;
        case 2:
          break;
      }
    }
    if (menuIDa == 4) { //Temp Menu
      switch (menuIDb) {
        case 0:
          lcdOut0 = "Hysteresis";
          lcdOut1 = rightPad(strcat(readEEprom("hysteresis"), "deg. F"),20);
          break;
        case 1:
          lcdOut0 = "Temp. Alerts";
          lcdOut1 = "Alerts go here.";
          break;
        case 2:
          break;
      }

    }
endPoint:
    //lcdOut0 = strcat('*', lcdOut0); //cursor

    Serial.println(lcdOut0);
    Serial.println(lcdOut1);
    Serial.println("----------");
  }
}
char* padRight(char* input, int padLength) {
  char* output;
  for (int i = 0; i <= padLength; i++) {
    output = strcat(output,' ');
  }
return output;
}

First, to get more effective help, you should start out with a clear, concise (but complete) problem statement of what you're trying to do. Then, you really need to learn how to write an MCVE so people don't have to wade through dozens of lines of irrelevant code. Also, "I get an the error" and "that didn't work either" are useless statements that provide no information. Post the complete error from the compiler and describe what "didn't work" means relative to the thing you're trying to accomplish.

Couple things I see just by scanning through:

lcdOut0 = "Auto/NTP Timeset";

You can't do c-string assignment this way. Use strncpy

output = strcat(output,' ');

The assignment operation is pointless. It's just setting the pointer variable 'output' to itself.

output = strcat(output,' ');

The assignment operation is pointless. It's just setting the pointer variable 'output' to itself.

[/quote]

That was an attempt to add spaces to pad out the cstring to twenty. I'm currently replacing all ='s with strncpy()

The error is the title: incompatible types in assignment of ‘char*’ to ‘char [20]’

I replaced all the ='s with strncpy and that error went away but I’m not out of the woods yet… once I find out what is going on I’ll post it.

strcat() does not take a char.

What data type is it for then?

strcat

I am trying to avoid using strings

Well, stop trying. It IS advisable to stop using Strings. The alternative is to use strings.

What data type is it for then?

char arrays.