I m getting mad with this. How to fix it working right using char arrays? I want a function put _address = address char array.
class Sensor{
public:
int id;
char address[30];
Sensor(int _id, char (*_address)[30]){
id = _id;
address = _address;
}
}
And how to use return method?
char* getAddress() {
return address;
class sensor_t
{
public:
int _id;
char* _address;
sensor_t(int const id, char* const address)
: _id(id)
, _address(address)
{ }
char* getAddress() const { return _address;}
};
Thanks. But how can I determine address size? Or what is the best way?
tolerance_zero:
But how can I determine address size?
I think you're going to have to pass it in, probably using the sizeof() operator.
system
March 25, 2016, 5:00pm
5
But how can I determine address size?
Addresses are always two bytes (on the Arduino).
If address is a string (a NULL terminated array of chars), strlen() will tell you the useful amount of data in the array. If address is not a string, then the called function can NOT determine the size of the array. It must be told the size.
Step back and tell us what you're trying to do, why and how you plan to use it.
Thanks lloyddean. Your code works than I thought. I just wanted to change strings to char arrays.
When you say "strings" what are you referring to; give me an example, or two, of these "strings" you wish to "change" into char arrays.