Thread: My intergars to strings doesn't work now >.<

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2006
    Location
    New York
    Posts
    124

    My intergars to strings doesn't work now >.<

    i was making a more simpilify way of converting numbers to words, and also handling zeros. My program stops at the first while!!!
    Code:
    #include <stdio.h>
       int  main(void) {
         	int temp,  num, count, R, sum[8],i, n[6], num1, timer = 0,w=0,x=0,  reg[11],  remainder,  tempCount=0;
              int value,value2, temp1,temp2,zero[6],temp_timer=0,p,zero_timer=0;
    	 int digit[10] = {10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};
    
    	char *word[11] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
    
                   		printf("Enter Number\n");
    
                   		scanf("%d",&num); // input number
    
                       		temp = num;
                       		count = 0;
    
       while (temp != 0)
    	{
    		temp = temp /10;
    		++tempCount;
    		printf("COUNT IS %d\n", tempCount);
    	}
    
    
    		temp = num;
    
    		  temp1= num;
    
    		  for(  ; temp1 != 0;     ) {
                                           temp1 = temp1 + 1;
               		          temp2  =  temp1%10;
    
    		     zero[temp_timer] =  temp2 - 1;
    
    		            temp1 = temp/10;
                                                ++zero_timer;
    
                                              ++temp_timer;}
    
    	                   printf("works here");
    	 while(temp != 0)
    		{
    
    			R= temp%10;
    
    			temp = temp / 10;
    
    			n[w] = R;
    
    		 	sum[x] = n[w] * digit[tempCount];
    				++ w;
    
    	               	   	 --tempCount;
    
    	       			++ timer;
    
      		                ++ x;
    
      		for(     ; timer != 0; --timer) {
                                         x = 0;
    
                                         value = 0;
    
                                   value2 = value + sum[x];
    
                                       value = value2;
    
    			          num1 = value2;
    
                                          ++ x; }
                                           }
    
            while(num1 !=0 && count < 10) 		 //divides number and puts it in a special container
                {
                		 remainder =num1 % 10;	//which prints the numbers that were broken
    
    		num1 = num1 / 10;      	//up into single digits to be printed into words
    
                 		reg[count] = remainder; 	// base on reg
    
             		 printf("reg[ %d ] is %d\n",  count, reg[count]);
    
    			 ++count;
    
    		 	}
    
    
    
    		if(temp_timer > count ) {
    
                      for(   p=zero_timer; p != 0; -- p) {
    
    			printf("%s", word[zero[p]]);   }   }
    
                         else
                                for(i=0; i<count; ++i)  {
    				printf("%s",word[reg[i]]);	}
                       }

    This program writes the number for the first time backwards then forwards the second time. >.> basically so it can print forward.....and if there are any zero it is handle by for and that number is printed otu if the count doesn't catch zero.
    Last edited by Darkinyuasha1; 10-08-2006 at 04:17 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  3. Replies: 9
    Last Post: 01-21-2004, 04:53 AM
  4. The Bludstayne Open Works License
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-26-2003, 11:05 AM
  5. Table mapping Strings to Strings
    By johnmcg in forum C Programming
    Replies: 4
    Last Post: 09-05-2003, 11:04 AM