Thread: beginner help

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    96

    beginner help

    i want to display the binary value for a character its not printing out can someone help me out please

    Code:
    
    #include<stdio.h>
    #include<conio.h>
    #include<iostream>
    #include<time.h>
    #define mask 128
    void getbinary(char ch);
    int main()
    {
         char c;
         int i;
         printf("Enter character=>");
         scanf("%c",&c);
         getbinary(c);
    
         printf("the binary value for %c is ",c);
         printf("\n");
        
              for (i=0;i<8;i++);
         {
              printf("hi %c",c);
                 if((c & mask)==0)
                 {
                 printf("0");
                 }
                 else 
                 {
                 printf("1");
                 }
                 c=c<<1;
          
          }
    
         getch();
    }
    void getbinary(char ch)
    {
         printf("ASCII value of '%c' is: has ASCII %i",ch, ch); 
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Code:
    for (i=0;i<8;i++);

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Ummm...
    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<iostream>
    #include<time.h>
    Is it random include file day?

    You could just drop conio.h and use a standard function like getchar(). Additionally, you defined main as returning an int however failed to do so in your program.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner help please
    By silas101 in forum C Programming
    Replies: 4
    Last Post: 10-23-2010, 11:22 AM
  2. Help Beginner
    By b-k24 in forum C Programming
    Replies: 13
    Last Post: 02-21-2009, 12:53 PM
  3. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM
  4. Help (Beginner)
    By NewbieC in forum C++ Programming
    Replies: 9
    Last Post: 01-29-2003, 02:26 PM
  5. A beginner in need
    By pneumo45 in forum C++ Programming
    Replies: 3
    Last Post: 06-11-2002, 10:17 PM