Need some help with TmpArray()

Hello everyone!
Today I am in need of assistance with some code usage.


1
2
char TmpArray[hello world!]; 
std::string


I am working on a project with it and need to know how it works.

My teacher said to look about arrays and the standard template library string. A link to documentation for this would be helpful.
Last edited on
Well, it looks like you've declared a character array called TmpArray.

The std::string on its own after that declaration makes no sense, though.
Character arrays:
http://cplusplus.com/doc/tutorial/ntcs/

1
2
char hello1[] = "Hello, World!"; // automatic size, just enough to fit the message
char hello2[200] = "How's it going?"; // size is 200, no matter the message 


STL std::string:
http://cplusplus.com/reference/string/string/

1
2
3
#include <string>

std::string hello("Hello, World!");


As a C++ programmer, you should favor using std::string (also called "C++ strings") instead of character arrays (also called "C strings").

std::string is easier to use, knows its own size, can be resized, etc.
Topic archived. No new replies allowed.