0% found this document useful (0 votes)
5 views3 pages

C++ Notes3

The document discusses the wchar_t data type in C++, which supports Unicode and varies in size depending on the compiler. It also introduces the bool data type, which occupies 1 byte and represents true or false. Additionally, it explains the difference between C-style strings and C++ strings, highlighting that C++ strings manage memory allocation automatically.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

C++ Notes3

The document discusses the wchar_t data type in C++, which supports Unicode and varies in size depending on the compiler. It also introduces the bool data type, which occupies 1 byte and represents true or false. Additionally, it explains the difference between C-style strings and C++ strings, highlighting that C++ strings manage memory allocation automatically.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

19/10

wchar_t

In computer world they follow


unicode table
universal code table, which contains the symbols and
alphabets of all the langauges which are worldwise
certified

size of wchar_t:
2 bytes on 16 bit compiler
4 bytes on 32 and 64 bit compiler

we use wcin and wcout for scaning and printing.


to change cuurent program locale we use c function called
setlocale

on 64bit compiler
wchar_t ch;
wchar_t s[10];
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello";
}

while(1) while(true)
{ {

} }

Boolean datatype bool

bool datatype occupies 1 byte of memory stores


true or false as 1 and 0
bool datatype recognises true and false as keywords
bool flag1=true;
cout<<flag1;
how do we declare a string

char str[20];
char s[30]="vector";
char s1[]="abcd";

to over come above problems, in c++ they introduced


string datatype
string s1;

in c++ style string programmer need not bother about


size , it is taken care by c++ compiler,
based on input accordingly memoey allocation done by
compiler
Note : c string predefined function will work only on cstyle strings
but not c++ style string.
char s[10]="vector";
string s1="vector";

You might also like