Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
Character ,Character Arrays and Strings
Character :
C/C++ support various characters (eg
...
„a‟
„f‟ ete
...
Initializing a character :
Char ch=‟a‟;
Reading a character from a terminal
The scanf () can be use with %c format specification to read
a character
...
(in C++ language)
Example:
Char ch;
Cin>>ch;
getchar( ) is also use to read a character
...
(in C language)
Example:
Char ch=‟k‟;
printf(“%c”,ch);
The cout<< is use to print/display a character
...
(in C/C++
language)
char ch=‟d‟;
putchar(ch);
Character Arrays /Strings:
C/C++ does not support string as a data type; however, it
allows us to represent string as character array
...
)
Any group of characters define between in a double quotation
marks is a string constant
...
Initializing a string :
char name[12]={„P‟,‟a‟,‟l‟,‟l‟,‟a‟,‟b‟,‟
‟,‟D‟,‟e‟,‟k‟,‟a‟,‟\0‟};
OR
char name[12]=“Pallab Deka”;
OR
char name[ ]={“Pallab Deka”};
OR
Char name[ ]={„P‟,‟a‟,‟l‟,‟l‟,‟a‟,‟b‟,‟
‟,‟D‟,‟e‟,‟k‟,‟a‟,‟\0‟};
When a compiler assigns a character string to a array, it
automatically supplies NULL character (‘\0’) at the end of
the string
Reading a string from a terminal
The scanf () can be use with %s format specification to read
a string
...
(in C++ language)
Example:
Char name[30];
Cin>>name;
gets( ) is also use to read a string
...
(in C language)
Example:
char name[ ]={“Pallab Deka”};
printf(“%s”,name);
The cout<< is use to display/print a string
...
(in C/C++
language)
char name[ ]={“Pallab Deka”};
puts(name);
(*We need not have to use loop statement to read /write
the characters of a string into the character array)
Some other library/inbuilt functions can be used to solve
string related problem
...
strcpy()------it is used to copies one string over another
...
etc