How to declare a string variable in C++ or string data type. Learn how to code in VS Code for free

preview_player
Показать описание

In VS Code, this is how to make a directory:
- go to terminal
- while in the directory enter "cd" without the quotes - this stands for change directory
- enter mkdir - this makes a directory, however, you need to add a name for the directory. It should look something like ex: mkdir exampleNameHere
- then you should change your directory, so cd and change it to the name of the file you want to go to
- ex: cd exampleNameHere
- enter code . for new file to load

Command line ( after Ubuntu install ): g++ -Wall -Wextra -pedantic -std=c++17

NOTES FROM VIDEO:

// ---- these allow you to write comments, as stated in the video.

Approved string variable type syntax formats:

string variableName;
std::string variable_Name;

Notice how each variable ends with a semicolon ( ; ). This is the syntax of the language and it is required. Additionally, in order to create a variable, you need a data type followed by an _approved_ variable name of your choice. While naming variables, they should be descriptive and clear. Variables should be named in accordance with what you're creating. Keep in mind others will be reading your code. Therefore, it's not all about you.

Don't forget to #include the string library
#include string (For some reason, I can't use angled brackets in this comment section. It's a YouTube thing. )
using std::string;

TERMS TO LOOKUP:

lookup how to name variables correctly in C++

assignment operator =
= not equal sign - this is the assignment operator
know what assignment operator means

syntax of C++ - at least have an understanding of what it means

preprocessor directive
STL
keyword include
stream insertion operator
stream extraction operator

iostream
cin
cout
endl

string
string variable
string literal
getline

Рекомендации по теме
join shbcf.ru