Error in function calls

I have following code and I am getting some errors. The errors are always in function calls.

#include <easyMesh.h>
#include <easyMeshSync.h>
#include <SimpleList.h>
#include <ESP8266WiFi.h>


#define   MESH_PREFIX     "WKI"
#define   MESH_PASSWORD   "WKI1234"
#define   MESH_PORT       5555

uint32_t ID;
String *msg[5];

easyMesh mesh;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  mesh.init("hhhh", "something", 5555);
  mesh.init( MESH_PREFIX, MESH_PASSWORD, MESH_PORT);
  ID=system_get_chip_id();
   
}

void loop() {

  // put your main code here, to run repeatedly:
//  mesh.init();                                //error is here
  mesh.update();
  Serial.println(ID);
  //mesh.setReceiveCallback( ID, &msg);       //error is here
  void newConnectionCallback( bool adopt );   //noerror

  mesh.sendBroadcast(&msg);          ////error is here
  //mesh.sendBroadcast(String &msg); // have also tried this.
  
}

Arduino: 1.8.3 (Windows Store 1.8.6.0) (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

C:\Users\UJJVAL\Documents\Arduino\easymesh\easymesh.ino: In function 'void loop()':

easymesh:35: error: no matching function for call to 'easyMesh::sendBroadcast(String* (*)[5])'

mesh.sendBroadcast(&msg); ////error is here

^

C:\Users\UJJVAL\Documents\Arduino\easymesh\easymesh.ino:35:26: note: candidate is:

In file included from C:\Users\UJJVAL\Documents\Arduino\easymesh\easymesh.ino:2:0:

C:\Users\UJJVAL\Documents\Arduino\libraries\easyMesh-master\src/easyMesh.h:105:25: note: bool easyMesh::sendBroadcast(String&)

bool sendBroadcast( String &msg );

^

C:\Users\UJJVAL\Documents\Arduino\libraries\easyMesh-master\src/easyMesh.h:105:25: note: no known conversion for argument 1 from 'String* (*)[5]' to 'String&'

exit status 1
no matching function for call to 'easyMesh::sendBroadcast(String* (*)[5])'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

void newConnectionCallback( bool adopt );  //noerrorno error, because it is a prototype.
Are you missing an array index?

Please remember to use code tags when posting code

what is code tags? Actually I tried but it was not there

ujjwalrathod007:
what is code tags?

Seriously?
You managed to find TTY tags and quote tags,
but not code tags?

Actually I tried but it was not there

You tried what?

An array name by itself is the memory address of where that array is stored in memory. Doing something like this:

  mesh.sendBroadcast(&msg);          ////error is here

It the coding equivalent of stuttering; you're sort of saying "the address of the address of msg". Get rid of the address-of operator (&). Also, what happens if you change this:

String *msg[5];
to this:

char *msg[5];

C strings (note lower case 's') are usually a better choice than the String class (note uppercase 'S'). If the library that you are using insists on the String object, the change won't work, but I'd be surprised if it was coded that way.

Finally, most C++ objects only need their init() method called once, and that usually takes place in the setup() function. Its purpose is to define the operating environment in which the object will be used. Once it's set, other properties and methods of the class are used to manipulate the object and the init() method is never called again.

so... here you define msg as an array of pointers to String objects:

String *msg[5];

your code (the library) is asking you to pass a String object:

C:\Users\UJJVAL\Documents\Arduino\libraries\easyMesh-master\src/easyMesh.h:105:25: note: bool easyMesh::sendBroadcast(String&)

bool sendBroadcast( String &msg );

^

you can see from the error that this is the function prototype:

bool sendBroadcast( String &msg );

if you define msg as a String:

String msg = "this is a test";

your code may work sending like this:

mesh.sendBroadcast(msg);

barring any other errors.

if your intention is to really utilize the array of pointers to String objects, you would need to define them:

String string0 = "String Zero";
String string1 = "String One";
String string2 = "String Two";
String string3 = "String Three";
String string4 = "String Four";

String* msg[] ={&string0, &string1, &string2, &string3, &string4};

and dereference the pointer...

mesh.sendBroadcast(*msg[0]); // note the index required...

the following works....

String msg="hello";
mesh.sendBroadcast(msg);