Lesson 9: Strings - Mastering C++ Fundamentals

preview_player
Показать описание
Master the basics of C++ with this set of lessons from Byte Academy and Embarcadero Technologies. Lesson 9 of 13.

C++ Fundamentals - Byte Academy Videos Playlist URL -

One of the most useful data types supplied in the C++ libraries is the string. A string is a variable that stores a sequence of letters or other characters, such as "Hello" or "May 10th is my birthday!". Just like the other data types, to create a string we first declare it, then we can store a value in it.

To subscriber to our channel, click the link below -

Embarcadero tools are built for elite developers who build and maintain the world’s most critical applications. Our customers choose Embarcadero because we are the champion of developers, and we help them build more secure and scalable enterprise applications faster than any other tools on the market. In fact, ninety of the Fortune 100 and an active community of more than three million users worldwide have relied on Embarcadero's award-winning products for over 30 years.

Appointments:

Address: 10801 North Mopac Expressway, Building 1, Suite 100, Austin, TX, 78759, United States

LET'S CONNECT!

Рекомендации по теме
Комментарии
Автор

also std::getline is better because you dont need a specific size;
Usage:
std::getline(input_stream, output_string, delimeter)
And to read a string normally just do this:
std::string name; //make a name variable as a real string, not a char array
std::getline(std::cin, name, ' '); // you dont need delimeter but i put one because yes
std::cout << name << std::endl; // and print it out
and you can get the string size using the .size() function

kenan
Автор

Also i found a bug in C++ Builder (the compiler)
If i declared an int:
int words;
and did this:
for(int i=0; i<in.size(); i++){
if(in[i] == ' ') words++;
std::cout << in[i] << ENDL;
}
and it says this:
There are 4198618 word(s) in test a b
but when i do:
int words = 0;
THEN:
There are 2 word(s) in test a b

Fix this embarcadero :o

kenan