19. strings (LB)
strings are 1d character array. e.g.,
char ch[10];
cin>>ch;
string ends with '\0'
cin with string works only if till space, tab or new line is absent in input...
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------
STRING-
dynamic size
no null termination
in built functions
----------------------------------------------------------------------------------------------------------------------------
To take a sentence as an input to a string-
string s;
getline(cin,s);
--------------------------------------------------------------------------------------------------------------
To convert a sentence into a vector of elements such that it takes substrings from string which are space separated-
-------------------------------------------------------------------------------------------------------------------------
In-Built functions-
1. int n = s.length();
int n = strlen(ch);
2. strcmp(s1,s2)-->gives 0 if both strings are equal 3. strcpy(dest,source)
-------------------------------------------------------------------------------------------------------------
Removing substring from a string-
-------------------------------------------------------------------------------------------------------------------------
Finding if a string s2 present in any permutation in s1- SLIDING WINDOW













Comments
Post a Comment