C/Data Type/Control Character

Материал из C\C++ эксперт
Перейти к: навигация, поиск

Back to the start of the line

<source lang="cpp">

  1. include <stdio.h> /* For input and output */

void main() {

  printf("%d ", 10);   /* Output a random digit          */
  printf("\r");                   /* go to beginning of the line */

}


      </source>


Displaying a String with line separator

<source lang="cpp"> /* Displaying a String with line separator */

  1. include <stdio.h>

void main() {

 printf("\n 1 \n                  2.");

}


      </source>


Displaying String: out quotation marks in a printf

<source lang="cpp"> /* Displaying String: out quotation marks in a printf */

  1. include <stdio.h>

void main() {

 printf("\n\"It is a wise father that knows his own child.\"  Shakespeare");

}


      </source>


Display string: special char

<source lang="cpp"> /* Display string: special char*/

  1. include <stdio.h>

void main() {

 printf("\nBe careful!!\a");

}


      </source>


More special chars

<source lang="cpp">

  1. include <stdio.h>

/* Include the header file for input and output */ void main() {

 printf("\n\n\n Three lines");
 printf("\n Special chars.\n\n\n\a\a");
 printf("\t \tA Tab \n");
 printf("\t \tA control character?\n");
 printf("\n\t\t\b\b more special chars?\n\n");

}


      </source>


Output control character: new line

<source lang="cpp">

  1. include <stdio.h>

int main(void) {

 printf("1.\n");
 printf("2.\n");
 printf("3.");
 return 0;

}

      </source>


Output new line character

<source lang="cpp">

  1. include <stdio.h>

int main(void) {

 printf("one\ntwo\nthree\nfour");
 return 0;

}

      </source>