Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Arrays/Heap.cpp
Original file line number Diff line number Diff line change
@@ -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 <iostream>
#include <array>
Expand Down
42 changes: 42 additions & 0 deletions String - Literals/Log.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <iostream>
#include <string>

#include <stdlib.h>

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 */
20 changes: 20 additions & 0 deletions String - Literals/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#include <string>

#include <stdlib.h>
#include <cstring>

/*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();
}
Binary file added String - Literals/main.exe
Binary file not shown.