Statement of the situation:
When making a banner, it was decided to convert part of the word into capital letters (CorelDRAW).
Questions:
What ways can you solve this problem?
How do you think in text editors what will happen as a result of pressing Shift + F3 or
The term string generally means an ordered sequence of characters, with a first character, a second character, and so on, and in most programming languages such strings are enclosed in either single or double quotes. In C++ the enclosing delimiters are double quotes. In this form the string is referred to as a string literal and we often use such string literals in output statements when we wish to display text on the screen for the benefit of our users. For example, the usual first C++ program displays the string literal "Hello, world!" on the screen with the following output statement:
cout << "Hello, world!" << endl;
Types of Strings
String Literals:
“Hello World”
“xyz 123 *&^#$!”
C-style strings:
char s[20];
C++ class string;
string s;
6
Literal String
7
null Character
Literal strings end in a null character: ‘\0’. (Character ‘\0’ has ASCII code 0.)
char s[] = “Hello World”;
s[0] equals ‘H’;
s[1] equals ‘e’;
. . .
s[8] equals ‘r’;
s[9] equals ‘l’;
s[10] equals ‘d’;
s[11] equals ‘\0’;
literalString2.cpp
cout << s << endl;
i = 0;
while(s[i] != '\0')
{
cout << s[i] << ",";
i++;
}
cout << endl;
cout << "s[" << i << "] = " << int(s[i]) << endl;
> literalString2.exe
Hello World
H,e,l,l,o, ,W,o,r,l,d,
s[11] = 0
ascii2.cpp
...
i = 0;
while(s[i] != '\0')
{
cout << setw(4) << s[i] << ",";
i++;
}
cout << endl;
i = 0;
while(s[i] != '\0')
{
cout << setw(4) << int(s[i]) << ",";
i++;
}
cout << setw(4) << int(s[i]);
cout << endl;
...
> ascii2.exe
Hello World
H, e, l, l, o, , W, o, r, l, d,
72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0
>
...
i = 0;
while(s[i] != '\0')
{
cout << setw(4) << int(s[i]) << ",";
i++;
}
cout << setw(4) << int(s[i]);
cout << endl;
...
Материалы на данной страницы взяты из открытых источников либо размещены пользователем в соответствии с договором-офертой сайта. Вы можете сообщить о нарушении.