Thread: char to binary

  1. #1
    Unregistered
    Guest

    char to binary

    hi i got a code where i have to find the binary equivalent of the string
    is ther any function that will convert from char to bainary ..or how would i solve this problem

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Good lord. Isn't this in the FAQ yet? This is posted every week. Since this is homework, and I know it is, how about you use the search button, eh?

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    19

    Wink

    I'm not sure but you may want to try something like this

    void convert( char ch)
    {
    int i;
    for(i=0;i<8;i++){
    if( ch & (1 << i)){
    printf("1");
    }
    else{
    printf("0");
    }
    }
    printf("\n");
    return ;
    }
    ~good monkeys, Excelent typewritters!...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 08-11-2008, 11:02 PM
  2. Wierd Segmentation Faults on Global Variable
    By cbranje in forum C Programming
    Replies: 6
    Last Post: 02-19-2005, 12:25 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. AnsiString versus char *
    By Zahl in forum C++ Programming
    Replies: 35
    Last Post: 10-16-2002, 08:38 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM