+ 8

What is the difference from string and char on c++??

Explanation about string and char

20th Mar 2018, 6:00 AM
ZĪ›RTHĪ›Š˜
ZĪ›RTHĪ›Š˜ - avatar
4 Answers
+ 8
A string is a collection of characters, specified within double-quotes. An example of a string literal: "This is a string" which can then be stored in a string variable: std:: string str = "This is a string"; A character is just, a character, within single-quotes. 'c' ' ' // whitespace character '\n' // newline character char c = 'c';
20th Mar 2018, 6:37 AM
Hatsy Rei
Hatsy Rei - avatar
+ 6
Can i ask.. Do i need insert "std::" every time when i am making some string and what exactly the function is...?? ā•®(Ā°_Ā°)ā•­
20th Mar 2018, 8:24 AM
ZĪ›RTHĪ›Š˜
ZĪ›RTHĪ›Š˜ - avatar
+ 5
std:: is to specify the standard namespace. You can do using namespace std; to omit the namespace before invoking objects from the std namespace, e.g. cout, instead of std::cout, string instead of std::string, etc. That said: https://www.sololearn.com/discuss/294730/?ref=app
20th Mar 2018, 9:54 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
array of characters is called string char a='c'; //char char a[10]="abcadhjkkkggh"; //string
24th May 2018, 5:59 AM
Vijay Kumar Kanchukommala
Vijay Kumar Kanchukommala - avatar