-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9_strings.cpp
More file actions
32 lines (28 loc) · 964 Bytes
/
9_strings.cpp
File metadata and controls
32 lines (28 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<iostream>
//#include<string>
using namespace std;
int main()
{
//using <string> from c++ header
string str="Hello There!";
string ful=" How are you??"; //don't use new as variable name
cout<< str<< endl;
cout<< str+ful<< endl; // string concatanation
//if wan to use function with concatanated string put
//those strings in bracket
cout<< (str+ful).length()<< endl;
str+="!"; //append string
cout<< str<< endl;
// from cstring // From C
// strings created using char array with terminating character
char name[]= "Caleb"; // 5 characters entered
cout<< sizeof(name)<< endl; //actual characters in name = 6
/*
C a l e b \0= terminating character
1 2 3 4 5 6
INDEX VALUES
0 1 2 3 4 5
\0 is displayed as null on output
*/
cout<< name[4]<< endl;
}