Skip to content

Commit b752db5

Browse files
committed
std to string
1 parent 50bd5af commit b752db5

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

content/posts/cpp-for-cscharp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,26 +759,26 @@ In C++ you use strings like so:
759759
// cpp
760760

761761
// creating a string
762-
string hello = "hello"; // c++ style
762+
std::string hello = "hello"; // c++ style
763763
char hello[] = "hello"; // plain c style
764764
char* hello = "hello"; // plain c style
765765

766766
// combining strings
767-
string combined = hello + "world";
767+
std::string combined = hello + "world";
768768

769769
// comparing strings
770770
bool test = ("apple" == "orange");
771771

772772
// number to string
773773
int age = 22;
774-
string message = to_string(age) + " years old";
774+
std::string message = std::to_string(age) + " years old";
775775

776776
// get length of string
777-
string test = "test";
777+
std::string test = "test";
778778
int length = test.length();
779779

780780
// indexing a string
781-
string test = "test";
781+
std::string test = "test";
782782
char index = test[0];
783783
```
784784

0 commit comments

Comments
 (0)