C/Data Type/Control Character

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

Back to the start of the line

#include <stdio.h>                     /* For input and output             */
void main()
{
   printf("%d ", 10);   /* Output a random digit          */
   printf("\r");                   /* go to beginning of the line */
}


Displaying a String with line separator

/* Displaying a String with line separator */
#include <stdio.h>
void main()
{
  printf("\n 1 \n                  2.");
}


Displaying String: out quotation marks in a printf

/* Displaying String: out quotation marks in a printf */
#include <stdio.h>
void main()
{
  printf("\n\"It is a wise father that knows his own child.\"  Shakespeare");
}


Display string: special char

/* Display string: special char*/
#include <stdio.h>
void main()
{
  printf("\nBe careful!!\a");
}


More special chars

#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");
}


Output control character: new line

  
#include <stdio.h>
int main(void)
{
  printf("1.\n");
  printf("2.\n");
  printf("3.");
  return 0;
}


Output new line character

  
#include <stdio.h>
int main(void)
{
  printf("one\ntwo\nthree\nfour");
  return 0;
}