-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_1_string.cpp
More file actions
38 lines (28 loc) · 848 Bytes
/
Copy path_1_string.cpp
File metadata and controls
38 lines (28 loc) · 848 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
33
34
35
36
37
38
#include<iostream>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
int main(){
//method 1 to declare a string as character-array
// char ch[20];
// cout<<"enter your name--> ";
// cin>>ch;
// cout<<ch<<endl;
// cout<<"size of ch is -->"<<sizeof(ch)<<endl;
//method 2 to declare a string
// string s;
// cout<<"enter the name2--> ";
// cin>>s;
// cout<<s<<endl;
// cout<<"size of s -->"<<sizeof(s)<<endl;
//method 3 to declare the string
string str(5,'m');
cout<<str<<endl;
//method 4 to declare the string
string str1="manishkumar";
cout<<str1<<endl;
// Method 5 to declare a string which is use to store a line of number of word with spaces.
string str2;
getline(cin,str2);
cout<<str2<<endl;
}