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.
28 questions
1
vote
1
answer
1k
views
Parse char* mac-string to uint8_t array
I have to handle a String coming in over UART containing a bunch of information, part of it is a MAC-address that I get by using String.substring(a, b) returning a 12-char String representing a mac-...
0
votes
2
answers
852
views
String() vs char for simple flow control
I am newbie in Arduino and writing a program where I want to control the flow by using Serial monitor input (PI controller).
I've read that using String() although easier it is slower than using char. ...
12
votes
6
answers
5k
views
Using String instead of C string, yet another attempt to touch a loaded issue
I've been reading a lot over the years why we should not use the notorious String class and how heap fragmentation is bad practice and not professional and we should never use it in our programs or we'...
1
vote
2
answers
1k
views
Arduino - Function -> return Cstr instead of string
I have following function for my Arduino:
String readLine() {
String received = "";
char ch;
while (myFile.available()) {
ch = myFile.read();
if (ch == '\n' or ch == '\r') {
...
-1
votes
1
answer
1k
views
Reading a string from Firebase and storing it as a CString
I have a mobile app (done using MIT App Inventor) storing some values to a Firebase database. App inventor stores all the values as strings (i.e. with quotes, and strings have quotes enclosed within ...
0
votes
1
answer
450
views
snprintf doesn't display float values
I don't understand why the formatted string is displaying ?? instead of float values.
My code:
#include <Arduino.h>
#include <Wire.h>
#include "SparkFunCCS811.h"
#include <...
1
vote
0
answers
602
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
2
answers
627
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
1
answer
3k
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
1
answer
728
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 ...
2
votes
1
answer
2k
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 the ...
10
votes
5
answers
69k
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 ...
0
votes
2
answers
3k
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
1
answer
2k
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 ...