C Tutorial/String/String Escape

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

Add new line character

#include <stdio.h>
int main(void)
{
  printf("A\nB\nC");
  return 0;
}
A
     B
     C

Escape Quotations

#include <stdio.h>
int main(void)
{
  printf("\n\"It is a wise father that knows his own child.\" Shakespeare");
  return 0;
}
"It is a wise father that knows his own child." Shakespeare

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

#include <stdio.h>
int main()
{
   printf(" \\ string.");
  
   return 0;
}
\ string.

Using escape: backslash

#include<stdio.h>
int main(void)
{
  printf("If at first you don\"t succeed, try, try, try again!");
  return 0;
}
If at first you don"t succeed, try, try, try again!