Thread: Character string

  1. #16
    Registered User FourAngels's Avatar
    Join Date
    Aug 2015
    Location
    Canada
    Posts
    130
    The draft definition is confusing it seems to twist its words, but I think that is because I do not fully understand what an integer is in terms of being an executable instruction. You have 32 bit operating systems and 64 bit operating systems. Is this because the integer size is 32 bits or 64 bits? Here we have an 8 bit integer type?

    The array is a character array, so that is why I believed that there is a conversion. I thought that the '0' + value was the result of beginning at '0' and adding value number of bytes to '0'. If it was the other way around than you would have value (a 64 bit number) plus '0' which is some other result.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by FourAngels
    The array is a character array, so that is why I believed that there is a conversion. I thought that the '0' + value was the result of beginning at '0' and adding value number of bytes to '0'. If it was the other way around than you would have value (a 64 bit number) plus '0' which is some other result.
    Ah. The thing is that when you have an expression like A + B, A and B are converted to a common type in what is known as the usual arithmetic conversions. So, it is not that the type of the expression is that of A: it could be the type of B instead, or sometimes neither. In this case, both operands (n % 10) and '0' are already of type int, so no further conversion is necessary. But, as the type of the destination is char (since s is a pointer to char, s[i++] is a char), there is a conversion from int to char, but it is in the C = D expression rather than A + B.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to read character by character without string.h?
    By Jimmy King in forum C Programming
    Replies: 2
    Last Post: 10-29-2013, 01:00 AM
  2. comparing character in a string to anothr character
    By merike in forum C Programming
    Replies: 5
    Last Post: 05-11-2007, 12:16 AM
  3. Replies: 3
    Last Post: 11-03-2002, 02:14 AM
  4. How to character in specified string !!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 07-17-2002, 09:17 AM
  5. Character in a String
    By DutchStud in forum Windows Programming
    Replies: 5
    Last Post: 12-14-2001, 07:39 AM