Latest web development tutorials

C Exercise Example 7

100 cases of classic C language 100 cases of classic C language

Title: output in a specific pattern, run, take a look, Very Beautiful in c environment!

Program Analysis: There are 256 characters. Different characters, graphics are not the same.

Chinese garbled (+ Cause Solution) VC6.0 appear next:

176 hexadecimal is B0,219 hexadecimal is DB, 0xB0DB within code "Bai" word, so the output is "Bai," the.

The main reason is the code page file information for different code pages the operating system we use Chinese state under, to display extended ASCII codes to be displayed in 437 OEM- United States, the following, so that you can show what you want. The default code page specific steps to modify the console as follows:

  • 1. Click on the top left of the interface running title bar icon [c: \], select the default value of a
  • 2. Modify the default code page, 936 (ANSI / OEM- Simplified Chinese GBK) to 437 OEM- United States
  • 3. Click to re-run after closing

Source Code:

//  Created by www.w3big.com on 15/11/9.
//  Copyright © 2015年 本教程. 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 above example output is:

100 cases of classic C language 100 cases of classic C language