* Add string.length() and string.size() example line
Adds a line under the Strings section to add total string length by
calculating the sum of two strings which have been given on output above
with their sizes found out using string::length() and string::size()
functions, with appropriate comment on this line.
Signed-off-by: Harshit Gupta <hkg1412@gmail.com>
* Add cstring strlen() example
Includes <cstring> header to demonstrate length of a character array
string which is C-compliant by using strlen() function available from
this header supported in C++.
Declared string is initialized with char array size [10] to just fit the
string contents with '\0' terminator.
Signed-off-by: Harshit Gupta <hkg1412@gmail.com>
---------
Signed-off-by: Harshit Gupta <hkg1412@gmail.com>
I've been learning from this site, and it seems good, and the general consensus online is that it's one of the better online tutorials/books for learning C++.
Just forcing http:// links to be https:// when possible.
I also read everything carefully and didn't find any mistake or easy improvements I could add (but I'm not that familiar with C++)
* Fix minor spelling / grammar problems ("tp de-allocate", "refences", "dont"...)
* Remove filler words ("Basically", "As a matter of fact"...)
* Remove spaces before parens in smart pointer initialization code sample (consistent with the other sections, e.g. the `Tuples` section)
* Clarify `std::weak_ptr` use case
* container -> vector
fixed errors:
- "vector_name" and "Vector_name" (different case) would have resulted in a compile time error, now: "my_vector"
enhancements:
- typedef for consistency
- two push_backs to show its purpose
- both iteration types now have a working execution block (both output the vector's content)
- the first "classic loop" now also shows the operator [], which therefor is removed from below
- include and for with a white spaces for readability
* removed the typedef
the `typedef` was used to show that we will be using `string` as our base for all operations, but we are free to use any other type; of course it is technically not needed and might look like a redundancy. the two `cin` also look redundant, so I changed this into one `cin` and two `push_back`s
Space should be removed.
before:
// concatenated_tuple becomes = (10, 'A', 1e9, 15, 11, 'A' ,3.14141)
after:
// concatenated_tuple becomes = (10, 'A', 1e9, 15, 11, 'A', 3.14141)
Typo initialize is correct form.
before:
map<char, int> mymap; // Will initalize the map with key as char and value as int
after:
map<char, int> mymap; // Will initialize the map with key as char and value as int
Typo corresponding is correct form.
before:
// To find the value correponsing to a key
after:
// To find the value corresponding to a key
* Added the Logical and bitwise operators section
* Added a note for Short Circuit evaluation
Excerpt from https://en.wikipedia.org/wiki/Short-circuit_evaluation
C++ uses minimal evaluation, or McCarthy evaluation (after John McCarthy (computer scientist)) is the semantics of some Boolean operators in some programming languages in which the second argument is executed or evaluated only if the first argument does not suffice to determine the value of the expression: when the first argument of the AND function evaluates to false, the overall value must be false; and when the first argument of the OR function evaluates to true, the overall value must be true. In some programming languages (Lisp), the usual Boolean operators are short-circuit.