Questions tagged [c-string]

A "C string" is an array of characters that ends with a 0 (null character) byte. The array, not any pointer, is the string.

Filter by
Sorted by
Tagged with
1
vote
0answers
53 views

Conversion from string to char array

I know this is Arduino Forum but I think this question is related to programming, I am using ESP8266 for the project. I need to convert the string incoming on the serial through UART lines and ...
0
votes
1answer
37 views

declaration of 'varDay' as array of references error

I am trying to write a function to store the date and time data from an RTC module. I have used char arrays to implement the function. I get "declaration of 'varDay' as array of references" ...
0
votes
2answers
38 views

Does toCharArray prevent a String being created on the heap?

I know it's bad to use Strings due to the memory problems that can occur. I've tried to remove all instances of strings from my code. But I'm not sure about this line: http.getString().toCharArray(...
0
votes
0answers
28 views

conver UUID to string for mqtt publish

I am trying to publish jason to mqtt. Following is just a snippet of a code.When i try to add data["uuid"] to json data doesn't get published to MQTT, if I omit data["uuid"] everything works. UUID is ...
0
votes
3answers
154 views

How to replace String objects with char arrays while still using string methods

I am running the following code on my ESP8266 (AI-Thinker ESP8266MOD). I send an HTTP GET request and a pin is set to high for a 1/2 second. However, after some time (sometimes 1hr, 2hrs, 12hrs, ...
0
votes
1answer
297 views

Convert JSON into string for MQTT

I am trying to publish json object into string with following snippet JSONVar data; data["chipid"] = chipId; data["co2_equivalent"] = co2_equivalent.c_str(); data["tvoc"] = tvoc.c_str(); data["...
0
votes
2answers
139 views

Yet another basic and silly question about C++ strings

I made a sketch like this: void setup() { // put your setup code here, to run once: Serial.begin(9600); char str1[64] = "test with spaces"; char str2[32] = "test with spaces"; Serial....
0
votes
1answer
298 views

Mqtt not subscribe on topic that's converted from String to char array

I am still not sure what should be the exact Title for this question, because I don't know where the problem is. I am using #include <MQTTClient.h> mqtt library to subscribe on a topic. This ...
0
votes
1answer
2k views

Splitting a Serial.readString into string array

I am working on a project where I need to split incoming data from serial (time to be exact, so aa:bb:cc) and need to split it into aa then bb and cc, ideally into an array. I know I could use ...
2
votes
1answer
875 views

Using c_str() on String for IPAddress with NTPClient provides wrong values

Libraries NTPClient Board Olimex ESP32-POE board Behaviour I have written a code that connects the board to a local NTP Server (which is an embedded board). I tried assigning the IP Address of ...
3
votes
2answers
8k views

Problems on convert byte[] to String

I'm reading a RFID Card from RC522 and send the data to my computer. My problem is the conversion of byte[] to String or std::string. #define SIZE_BUFFER 18 #define MAX_SIZE_BLOCK 16 byte ...
3
votes
5answers
8k views

formatting strings in Arduino for output

I wander what is the best option for formatting strings in Arduino for output. I mean what's a preferable way in the point of view of performance, memory usage – things like that. I see, people ...
1
vote
1answer
3k views

Char* and string conversion from an ESP8266 web server

I have the following Arduino code for configuring a wifi connection through a simple webpage: I declare char* ssid;. Later I read a value from a SPIFFS config file where q_ssid is declared as a ...
0
votes
2answers
2k views

Arduino GSM module + SMS string sending garbage value

I want to check the water level and have an SMS sent via a GSM module. Reed switches are connected to four Arduino analog inputs. I am unable to add a string and tank level (TKLVL) in program. The ...
0
votes
2answers
3k views

Max length of char arrays?

I'm running the following Sketch on my Arduino Uno: const boolean verbose = true; void debug(const char *s){ if(verbose){ char buf[8 + sizeof(s)] = "[DEBUG] "; strcat(buf, s); ...
0
votes
1answer
921 views

Store 3-dimensional char array in program memory with PROGMEM

I'm running a sketch whith a quite big, constant three dimensional char array (or simply, a table of strings). As this takes lots of RAM I'd like to store it in programm memory in order to keep the ...
8
votes
1answer
73k views

Convert int to char[]

I'm looking to convert an int value to a char array. currently I've found the following will return [number] int num = [number] str = String(num); str.toCharArray(cstr,16); Serial.println(cstr); ...