All pastes #342561 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-06 11:48 UTC
rendered paste body
#include <stdio.h>

char* crtBitStr(unsigned int x);
unsigned int zeichen;
char* ausgabe;
char vBuf[128];


int main()
{  printf("Bitte geben Sie eine Zahl ein !!!");
   fgets(vBuf,128,stdin);
   sscanf(vBuf,"%u",&zeichen); 
   ausgabe=crtBitStr(zeichen);
   printf("%s ", ausgabe);  //schleife noch drum bauen

  return 0;
}

char* crtBitStr(unsigned int x)
{  char feld[ sizeof(x)*8 + sizeof(x)-1 +1 ];
   int size = sizeof(x)*8 + sizeof(x)-1 +1;
   int i;
   for(i=size-1; i>=0; i--)
   {
    if(i%9==8)
    {
     feld[i]='|';
     i=i-1;
    } 

    if(x%2==0) feld[i]='0';
    else feld[i]='1';
    x=x/2;
   }
   
   return feld;
}