C Tutorial/String/String Escape

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

Add new line character

<source lang="cpp">#include <stdio.h> int main(void) {

 printf("A\nB\nC");
 return 0;

}</source>

A
     B
     C

Escape Quotations

<source lang="cpp">#include <stdio.h> int main(void) {

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

}</source>

"It is a wise father that knows his own child." Shakespeare

\\ is the escape sequence that sticks a backslash character into a string.

<source lang="cpp">#include <stdio.h> int main() {

  printf(" \\ string.");
 
  return 0;

}</source>

\ string.

Using escape: backslash

<source lang="cpp">#include<stdio.h> int main(void) {

 printf("If at first you don\"t succeed, try, try, try again!");
 return 0;

}</source>

If at first you don"t succeed, try, try, try again!