string literals in c 2b 2b

Solutions on MaxInterview for string literals in c 2b 2b by the best coders in the world

showing results for - "string literals in c 2b 2b"
Luis
29 Jun 2016
1#include <iostream>
2#include <string>
3#include <stdlib.h>// using c standard library
4int main()
5{
6
7	"Caleb";//String literal is a series of characters between two double quotes
8	//It is a const char array and array is  just a ptr to a begining of block of memory
9	//String literals are stored in read only section of memory
10
11	const char name[8] = "Rhe\0eno";// \0 is null termination character
12	std::cout << strlen(name) << std::endl;//c function for size of string ,output => 3 due to null terminating char \0
13	std::cout << name << std::endl;// output => Rhe because null termination char \0
14
15	const char* name1 = u8"Caleb";//1 byte per char
16	const wchar_t* name2 = L"Caleb";//is 2 or 4 bytes per character dependent on compile on windows it's usually 2bytes but on linux it is 4 bytes per char
17	const char16_t* name3 = u"Caleb";//2 byte per char
18	const char32_t* name4 = U"Caleb";//4 byte per char
19
20
21	using namespace std::string_literals;
22	// this name space give   number of functions for convenience
23
24	//std::string name0 = "Caleb" + "hello";//error because can't add ptr to ptr
25	std::string name0 = "Caleb"s + "hello";//s is an operator that returns std::string this will work because now adding a ptr to actual string
26	//various versions of strings
27	std::wstring namee = L"Caleb"s + L"hello";//wide string: 2 or 4 bytes depend on compiler
28	std::u32string namee32 = U"Caleb"s + U"hello";//u 32 string :4 bytes per char
29	std::u16string namee16 = u"Caleb"s + u"hello";//u16 string :2bytes per char
30	std::string namee8 = u8"Caleb";//1 byte per character
31	const char* example = R"(Line1
32Line 2
33Line 3 
34Line 4 
35)";//R:Raw  for writing on different lines it prints escape characters 
36	std::cin.get();
37
38};
River
09 Jan 2018
1string literal
queries leading to this page
template literals in c 2b 2bc 2b 2b user defined string literalsc static string prefix utf16c 2b 2b which string literal should i usec 2b 2b normal stringc 2b 2b only acceps string literalscharacter literals in c 2b 2bc 2b 2b string literal as template parameterliteral string c 2b 2bc 2b 2b what are literalsc 2b 2b literals operatorwhat is the definition of a literal in c 2b 2bliteral keyword c 2b 2bc 2b 2b style string literalliterals vs data types in c 2b 2busing string literals c 2b 2bc 2b 2b r before string literalc 2b 2b raw literal stringcerate string literal in c 2b 2bl string and rstringdefine a literal character c 2b 2bliterals in c 2b 2b examplec 2b 2b what kind of literals are therec 2b 2b11 string literalc 2b 2b is string literalc string prefixesstring literal cppdefine string literal c 2b 2bwhat is the character literal in c 2b 2bc 2b 2b string literalexamples of string literals in c 2b 2bstring literals in c 2b 2bdefine literals in c 2b 2bstring literal declarationstring literals c 2b 2bc 2b 2b string r 22string literal u 28 29 c 2b 2bstring literal c 2b 2bwhat is the point of a literals in c 2b 2bwhen was string literall added in c 2b 2bc 2b 2b r in front of stringc 2b 2b declare wstring literalfind all the literals in c 2b 2b stringc 2b 2b r string prefixliterals in cppc 2b 2b string literall 40literal in cppc 2b 2b char 5crc 2b 2b 11 raw string literalc 2b 2b string literalsc 2b 2b string litteralc unicode string literalc 2b 2b string literals sufixstring object and string literal in c 2b 2bc utf 8 string literalwhat is mean by literals in c 2b 2bwhat are literals in c 2b 2braw string literals in c 2b 2braw string c 2b 2bcpp literalscppreference string literalhow to identify literals in c 2b 2b codec 2b 2b custom string literal literals in c 2b 2bformat r srting c 2b 2bwhat are literals in c 2b 2b 3fc 2b 2b raw string literalc 2b 2b text literalsliteral 22 22s for string c 2b 2binclude in string literal c 2b 2bstring literals c 2b 2b and stringc 2b 2b literal string rcpp string literalc 2b 2b literalsliterals in c 2b 2bc 2b 2b 11 string literalc 2b 2b 23define string literalc 2b 2b std string literal operatorc 2b 2b r stringstring literals c 2b 2b14what is literals in c 2b 2bc 2b 2b string 22 2fr 22u8 to string c 2b 2bc 2b 2b raw literalliterals c 2b 2btow string literal cppwhat are literals c 2b 2bstring literals in cppstring literal in c 2b 2bc 2b 2b literal stringc 2b 2b string literal manipulationc 2b 2b literal string 2b11how to define a string literal in c 2b 2bc 2b 2b string r prefixstring literal u 28 22 22 29 c 2b 2bvalide integer c 2b 2b string literaltemplate string literal c 2b 2bstring literals in c 2b 2b