What is the difference between string and char[] in c++?

Asked 2 years ago, Updated 2 years ago, 41 views

string strTest = "Hello"; has a size of 5 charTest[] = {'H', 'e', 'l', 'l', 'o'}; has a size of 5.

What is the difference between string and char[]?

c++ string type

2022-09-20 21:29

1 Answers

String is a class, char x[] is an array of characters. Character arrays can only store characters, and the class contains various functions in addition to storing, so you can use them if necessary.


2022-09-20 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.