C Exercise Example 7

100 Classic C Examples

Title:Output special patterns. Please run it in a C environment and take a look. Very Beautiful!

Program analysis:There are 256 characters in total. Different characters have different graphics.

Chinese garbled text appears under VC6.0 (cause + solution):

The hexadecimal of 176 is B0, the hexadecimal of 219 is DB, and 0xB0DB is the internal code of the character "佰", so the output is "佰".

The main reason is that the code page of the file information is different. The code page used by our operating system in the Chinese state. To display extended ASCII codes, you need to display them under 437 OEM-United States, so that you can display what you want. The specific steps to modify the console's default code page are as follows:

  • 1. Click the title bar icon 【c:\】 in the upper-left corner of the run interface, and select the default value option.
  • 2. Modify the default code page from 936 (ANSI/OEM - Simplified Chinese GBK) to 437 OEM - United States
  • 3. Just close it and rerun it

Example

// Created by www.example.com on 15/11/9. // Copyright © 2015 Example. All rights reserved. // #include<stdio.h> int main() { char a=176,b=219; printf("%c%c%c%c%c\n",b,a,a,a,b); printf("%c%c%c%c%c\n",a,b,a,b,a); printf("%c%c%c%c%c\n",a,a,b,a,a); printf("%c%c%c%c%c\n",a,b,a,b,a); printf("%c%c%c%c%c\n",b,a,a,a,b); return 0; }

The output result of the above example is:

100 Classic C Examples

other extensions