GCC programming summary in Linux 1 (error: stray ''' in Program)

Source: Internet
Author: User

Error: stray '\ 302' in program

For those who have already encountered this error"Error: stray '\ 302' in program"Or something similar while compiling a program in C:
Fool @ localhost :~ $ Gcc-O hello_world hello_world.c

Hello_world.c: In function 'main ':
Hello_world.c: 5: Error: stray '\ 302' in program
Hello_world.c: 5: Error: stray '\ 304' in program

Either you have to remove the entire line (here line 5), or you just have to remove some trailing characters. sometimes, while writing into a text editor, some non-ASCII characters are inserted accidentally.

The main cause is the incorrect use of full-width and half-width characters during programming. Note:

During programming, only half-width punctuation can be used, and full-width punctuation cannot be used. Note: The following is an article on the Internet:

Check it out.

What is a fullwidth and halfwidth? (1) fullwidth: A character occupies two standard characters. Chinese characters and the English characters that specify the full angle and the graphical symbols and special characters in the national standard GB2312-80 are all full-angle characters. Generally, system commands do not use full-width characters, but only use full-width characters during text processing. (2) halfwidth: A character occupies a standard character position. Generally, English letters, number keys, and symbol keys are half-width, and the half-width display inner code is one byte. In the system, the above three characters are processed as the basic code. Therefore, users generally use half-width characters when entering commands and parameters. Under what circumstances does B's fullwidth and halfwidth work? The width occupies two bytes, and the width occupies one byte. The halfwidth width is mainly for punctuation marks. The fullwidth punctuation marks take two bytes, And the halfwidth occupies one byte. The Chinese Character occupies two bytes, whether it is halfwidth or fullwidth. Only halfwidth punctuation can be used in the source code of the Program (excluding the data inside the string) only halfwidth punctuation can be used on computers that do not support Chinese characters and other languages (in fact, this situation does not have the concept of halfwidth fullwidth). For most fonts, The fullwidth seems bigger than the halfwidth, of course, this is not an essential difference. The difference between full-width and half-width C is that letters, numbers, and other characters occupy the same width as Chinese characters. The halfwidth is an ASCII character. The letters, numbers, and characters entered when there is no Chinese Character Input Method. When the Chinese character input method appears, the entered letter and number are half-width by default, but the punctuation is full-width by default. You can click the corresponding button on the input method toolbar to change it. D about "full angle" and "half angle": full angle: refers to the GB2312-80 ("information exchange with Chinese character encoding Character Set-basic set") in a variety of symbols. Halfwidth: it refers to the symbols in the ASCII code of English files.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.