User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 397,789 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,425 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:

Special Characters in C++

Join Date: Feb 2006
Location: UK
Posts: 468
Reputation: Bench has a spectacular aura about Bench has a spectacular aura about Bench has a spectacular aura about 
Rep Power: 5
Solved Threads: 42
Bench's Avatar
Bench Bench is offline Offline
Posting Pro in Training

Re: Special Characters in C++

  #6  
May 18th, 2006
So I try "\-126" and get a compile error. Any other ideas?
"\-126" isn't a char, the double quotes translate that you are attempting to use a string literal, which isn't what you want. There should be no need for the backslash either, since you're not using an escape character.

Just to re-iterate, this is not a C++ issue, this is an implementation-specific font issue. The windows 2000 cmd.exe console uses the "Terminal" font, hence why I got a value of -126 (or 0x82) for the 'é' character. if your implementation uses a different font, there's a strong possibility that the number -126 is not what you need (The code in my earlier post is indifferent to the font)

rambling aside - here is how you might print the é character, if your output uses the Terminal font.
#include <iostream>

int main()
{
    char c = -126;
         // you could also use 0x82 instead of -126
    std::cout << c;
}
or..
#include <iostream>

int main()
{
    std::cout << static_cast<char> (-126);
}

You may also be able to change your IDE to use the same font as your console window, although I haven't tested that idea.
¿umop apisdn upside down?
Reply With Quote  
All times are GMT -4. The time now is 5:24 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC