DEV Community

Cover image for Maxsus belgilar | C++ boshlang'ich
Imron
Imron

Posted on • Edited on

Maxsus belgilar | C++ boshlang'ich

String va maxsus belgilar
Tekstlar string de b ataladi va qo'shtirmoq ichida " " orasida yoziladi.

cout << "Hello world" << endl;
Enter fullscreen mode Exit fullscreen mode
  1. \ - escape character
  • ushbu belgi string/tekst ichida maxsus komandalar/belgilar yozish uchun ishlatiladi.

" ni chiqarish

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

Bu xato! Chunki kompyuter"zo'r"ni string tugadi deb o‘ylaydi.

Shuning uchun:

cout << "U \"zo'r\" bola";

Enter fullscreen mode Exit fullscreen mode

Natija:

U "zo'r" bola
Enter fullscreen mode Exit fullscreen mode

\ ni o‘zini chiqarish

Agar bitta \ chiqarmoqchi bo‘lsak:

cout << "\\";

Enter fullscreen mode Exit fullscreen mode

Chunki:

Birinchi \ → buyruq boshi

Ikkinchisi → chiqariladigan belgi

\
Enter fullscreen mode Exit fullscreen mode

Natijada : \ bitta beradi.

  1. \n — yangi qator

Bu Enter bosgandek ishlaydi.

cout << "Salom\nDunyo";

Enter fullscreen mode Exit fullscreen mode

Natija:

Salom
Dunyo

Enter fullscreen mode Exit fullscreen mode

3 \t — katta bo‘sh joy (Tab)

cout << "olma\tanor\tbexi";

Enter fullscreen mode Exit fullscreen mode

Natija:

olma    anor    bexi

Enter fullscreen mode Exit fullscreen mode

4 \r — qator boshiga qaytish

\r kursorni qator boshiga olib boradi va ustidan yozadi.

cout << "Salom\rDunyo";

Enter fullscreen mode Exit fullscreen mode

Natija:

Dunyo

Enter fullscreen mode Exit fullscreen mode

\ — maxsus buyruq boshlovchi

\" — " chiqaradi

\ — \ chiqaradi

\n — yangi qator

\t — tab joy

\r — qator boshiga qaytadi

Top comments (1)

Collapse
 
whysoempty profile image
Imron

Good