CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Binary representation of the character value

  1. #1
    Join Date
    Jan 2015
    Posts
    100

    Post Binary representation of the character value

    We want to create a table in such a way that each character value is represented by a 6 bit binary value if i enter a character it should represent in binary.Can any one help me out in finding logic in c program.


    000001 A
    000010 B
    000100 C


    if i enter CA the binary digit as to be stored in format 000100000001

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,144

    Re: Binary representation of the character value

    So the first step is to devise an algorithm on paper that given a character will produce the required binary representation. Once you have this working on paper then the next step is to translate this algorithm into the program. So you need to determine on paper how to convert 'C' into 000100. What does D, E etc convert into? What is the pattern. Given pen and paper, how would you convert F into the required binary etc.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.6.3)

  3. #3
    Join Date
    Jan 2015
    Posts
    100

    Re: Binary representation of the character value

    thanks

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,607

    Re: Binary representation of the character value

    Quote Originally Posted by Jeevan Rudramurthy View Post
    We want to create a table
    The very first step, always and unconditionally, is clear and consistent explanation of the requirements.

    The very first step to clear and consistent explanation is identifying points that may sound ambiguous.
    The very second step is resolving the ambiguities into something straight and solid and specific. Only then you can design the feature properly.

    What does those "create a table" and "to be stored" really mean? Table on paper? Table in text file? Table in database? Table in memory? You see what I mean? There's nothing to start with until you explain yourself clear.
    Best regards,
    Igor

  5. #5
    Join Date
    Mar 2001
    Posts
    2,527

    Re: Binary representation of the character value

    Does it have to follow that particular pattern? It would be relatively easy to offset and reduce ASCII a little and make that fit your scheme.
    ahoodin
    To keep the plot moving, that's why.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)