diff --git a/Arrays/Heap.cpp b/Arrays/Heap.cpp index 9be34ee..2dfc0de 100644 --- a/Arrays/Heap.cpp +++ b/Arrays/Heap.cpp @@ -1,4 +1,4 @@ -//there is no way of knowing the size of array in c++;but there is a way cause when you delete this heap memry compiler needs to know the size of array but its comprimising +//there is no way of knowing the size of array in c++;but there is a way cause when you delete this heap memory compiler needs to know the size of array but its comprimising #include #include diff --git a/String - Literals/Log.cpp b/String - Literals/Log.cpp new file mode 100644 index 0000000..601ab17 --- /dev/null +++ b/String - Literals/Log.cpp @@ -0,0 +1,42 @@ +#include +#include + +#include + +int main() +{ + + using namespace std::string_literals;//gives no of funtions for convenience + + std::string name0 = std::string("Cherno") + "hello!";//cant do cause you cant add 2 raw literals directly + std::string name0 = "Cherno"s + "hello!";//this s returns a standard string and u8 for normal string and L infront of the string literals for wide string + + + std::u32string name0 = U"Cherno"s + U" hello";//for wide string it is wstring and R for row + + const char* example = R"(Line1 + Line2 + Line3 + Line4)"; + + const char* ex = "Line1\n" + "Line2\n" + "Line3\n"; + + + + const char* name = u8"Cherno";//made with utf 8 similar to remaining ones [ unicode transformation format ] + const wchar_t* name2 = L"Cherno";//wide and this is 2 bytes per character[but variable for such as linux and windows] + + const char16_t* name3 = u"Cherno";//2 bytes per character or 16 bits a character using string + const char32_t* name4 = U"Cherno";//32 bits character or 4 bytes per character + + + + std::cin.get(); +} + +/*string literals are always stored in read only memory + so i cant equate a char pointer to a string litreral + which is a READ ONLY MEMORY + we can use a const char array */ \ No newline at end of file diff --git a/String - Literals/main.cpp b/String - Literals/main.cpp new file mode 100644 index 0000000..9ebf11f --- /dev/null +++ b/String - Literals/main.cpp @@ -0,0 +1,20 @@ +#include +#include + +#include +#include + + /*just a standard c library include 3 funtions and + its a string literal also written as + "Suhas"; 0[this is numeric zero]*/ + +int main() +{ + const char name[8] = "Che\0rno"; + + /*8 cause it even ends with \0*/ + + std::cout << strlen(name) << std::endl; + + std::cin.get(); +} \ No newline at end of file diff --git a/String - Literals/main.exe b/String - Literals/main.exe new file mode 100644 index 0000000..c01c629 Binary files /dev/null and b/String - Literals/main.exe differ