Oke,
I changed it to this:
Code:
/*
* * =====================================================================================
*
* Filename: test2.c
*
* Description: conventer from dec to 0101
*
* Version: 1.0
* Created: 14-05-11 10:03:25
* Revision: none
* Compiler: gcc
*
* Author: Dr. Fritz Mehner (mn), [email protected]
* Company: FH Südwestfalen, Iserlohn
*
* =====================================================================================
*/
#include <stdio.h>
#include <stdlib.h>
int
main ( int argc, char *argv[] )
{
int nummer, uitkomst, teller;
char uitkomst2[10];
nummer = 2 ;
uitkomst = 2 ;
teller = 0 ;
while (uitkomst > 0)
{
uitkomst2[teller++]= uitkomst%2;
uitkomst = nummer /2 ;
nummer = uitkomst;
printf ("teller:%d deling:%d uitkomst deling:%d \n",teller, uitkomst%2, uitkomst);
}
printf ("teller is nu %d", teller);
while (teller > 0)
{
printf("%d", uitkomst2[teller]);
teller = teller - 1;
}
return EXIT_SUCCESS;
}
/*c---------- end of function main ---------- */
But i see something wierd.
The output is now this
Code:
teller:1 deling:1 uitkomst deling:1
teller:2 deling:0 uitkomst deling:0
teller is nu 241
So the loop is executed right but after that teller is a complete other number.
Roelof