Getting ASCII character warning

This is a discussion on Getting ASCII character warning within the C++ Programming forums, part of the General Programming Boards category; I have the following line of code to help me draw the screen Code: char topLeft = 201; char horizontalLines ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    610

    Getting ASCII character warning

    I have the following line of code to help me draw the screen

    Code:
        char topLeft = 201;
        char horizontalLines = 205;
        char topRight = 187;
        char verticalLines = 186;
        char bottomLeft = 200;
        char bottomRight = 188;
    these characters are from here. But now i get warnings

    Code:
    warning C4309: 'initializing' : truncation of constant value
    Is there a way i can avoid this warning?

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    A 'char' type may either be signed or unsigned, that is implementation dependent. It is apparently signed in your implementation, meaning the maximum value is 127. You'll need to use 'unsigned char' to be able to store one-byte values which most often have 8 bits.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,594
    In VS, all chars are signed by default.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    thanx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 03:33 PM
  3. Extended character ASCII in LINUX/WINDOWS
    By intmail in forum Linux Programming
    Replies: 2
    Last Post: 01-26-2006, 02:24 PM
  4. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  5. Replies: 1
    Last Post: 07-31-2002, 10:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21