Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert character array to string in Arduino
In order to convert a character array to a string, the String() constructor can be used. An example is shown below −
Example
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println();
char buf[10] = "Hello!";
Serial.print("Char array: ");
Serial.println(buf);
String s = String(buf);
Serial.print("String: ");
Serial.println(s);
}
void loop() {
// put your main code here, to run repeatedly:
}
The output of the Serial monitor is shown below −
Output

Advertisements