Maxsus belgilar | C++ boshlang'ich

islomali99

islomAli99

Posted on April 29, 2024

Maxsus belgilar | C++ boshlang'ich

string va maxsus belgilar

Avvalgi postimizda yozganimizdek, C++ tilida tekstlar string deb ataladi va qo'shtirnoq ichida " " orasida yoziladi.

cout << "Salom Dunyo" << endl;
Enter fullscreen mode Exit fullscreen mode

1.\ - escape character

  • ushbu belgi string/tekst ichida maxsus komandalar/belgilar yozish uchun ishlatiladi.

string ichida yozish mumkin bo'lmagan ba'zi belgilar mavjud. Masalan: U "zo'r" bola. deb chop etish uchun C++ da "U "zo'r" bola." deb yozish xatolik beradi. BUnga sabab string ichida " belgisi ishlatsa, string tugaganini anglatadi.

string ichida shunga o'xshash ta'qiqlangan belgilarni yozish uchun \ ishlatiladi.

cout << "U \"zo'r\" bola." << endl;
Enter fullscreen mode Exit fullscreen mode

\ belgisini o'zini chop etish uchun nima qilamiz ?

\\ qilib yoziladi

cout << "Bugun \\ belgisini asl kuchini ko'rdik!" << endl;

----------natija-----------
Bugun \ belgisini asl kuchini ko'rdik!
Enter fullscreen mode Exit fullscreen mode

2.\n - yangi qator

  • ushbu maxsus belgi string register ichiga yozilsa, shu string ni chop etishda \n bor joydan boshlab keyingi qator o'tib ketadi.
cout << "Salom\nDunyo" << endl;

--------------natija-------------
Salom
Dunyo
Enter fullscreen mode Exit fullscreen mode
  1. \t - Tab (tabulation)
  • string ichiga yozilganda tekst ichiga TAB bo'sh joy chop etadi
cout << "olma\tanor\tbexi" << endl;

------------natija-----------
olma   anor   bexi
Enter fullscreen mode Exit fullscreen mode
  1. \r - carriage return
  • chop etilayotgan qatorda kursorni qator boshiga olib keladi. Yana chop etishda davom etilsa avval yozilgan tekstlarni o'chirib ustiga yozib yuboradi.
cout << "Github 'vashshe' malades  \rIlmhub" << endl;

----------natija--------
Ilmhub 'vashshe' malades
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
islomali99
islomAli99

Posted on April 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Maxsus belgilar | C++ boshlang'ich
beginners Maxsus belgilar | C++ boshlang'ich

April 29, 2024