简体   繁体   中英

Special characters C/C++

When I compile the code below, using NetBeans, the output of the program is some strange characters in the terminal (teste á é õ). Unfortunately I could not find the solution for this.

Has anyone experienced this? Know the solution?

#include <stdio.h> 
#include <locale.h> 

int main(int argc, char** argv) { 
setlocale(LC_ALL,""); 
printf("teste á é õ"); 
return (0); 
} 

My compiler is MinGW, my native language is Brazilian Portuguese.

样本配置和版本

output:

输出

They are not Ascii Characters.

ASCII characters 0-31 are various space characters and there is no standardized way to print them. This is an "extended ASCII table". There is no guarantee that those exact symbols will be printed on your particular platform.

They work fine for me in Windows 7, tested with GCC and Embarcadero C++, both print those symbols. But on another OS and/or compiler, different symbols or nothing at all might be printed.

Only ASCII characters 32 - 126 are guaranteed to be printable, and the same symbol, on all systems.

C++ is an English language and can only print the original ASCII code from English, some 3rd party libraries such as Curses let you get around this and print some non-ASCII ones found here: http://www.melvilletheatre.com/articles/ncurses-extended-characters/index.html

But for the most part, I can't see why you would want to print these characters since there is no practical purpose.

Other explanation: You can't do this since the original ASCII code consists of 127 types. Binary and stuff, different answer to the question, so just know their are only 127 possible letters allowed, more can be found here. enwikipedia.org/wiki/ASCII and williamrobertson.net/documents/ascii.html (This one gives you what can actually be printed by C++)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM