Click here to Skip to main content
15,899,754 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: how to format numbers with dollar sign in a cell for a CListCtrl Pin
David Crow1-Jun-10 5:08
David Crow1-Jun-10 5:08 
AnswerRe: how to format numbers with dollar sign in a cell for a CListCtrl Pin
PJ Arends1-Jun-10 5:52
professionalPJ Arends1-Jun-10 5:52 
Question.:: How to convert a gotten int input into a char or string which each of their elements can be accessable separately? [C++] Pin
bijan.8k31-May-10 7:29
bijan.8k31-May-10 7:29 
AnswerRe: .:: How to convert a gotten int input into a char or string which each of their elements can be accessable separately? [C++] Pin
Luc Pattyn31-May-10 7:35
sitebuilderLuc Pattyn31-May-10 7:35 
AnswerRe: Try this code Pin
Software_Developer31-May-10 8:28
Software_Developer31-May-10 8:28 
GeneralRe: Try this code Pin
bijan.8k31-May-10 9:02
bijan.8k31-May-10 9:02 
GeneralRe: Try this code Pin
Software_Developer31-May-10 9:52
Software_Developer31-May-10 9:52 
GeneralRe: Now it is just clunky Pin
Software_Developer31-May-10 17:38
Software_Developer31-May-10 17:38 
Now it is just clunky



   //         one                ten              hundred              thousand
   //          1                  2                  3                    4
   //digitn=digitArray[3]*1 + digitArray[2]*10 +digitArray[1]*100 +digitArray[0]*1000

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>


int digit=0,digitInput=0;
int digitArray[10]={0},digitn;
 
/*********************************
 *                               *
 ********************************/

void getIntKey(void)
{
   digitArray[0]=0;
   digitArray[1]=0;
   digit=0;
   digitInput=0;

   while((digit<9))
   {
	   if (kbhit())
	   {
		   digitInput=getch();
		 
		   if ((digitInput>47) && (digitInput<59))
		   {
	                 digitArray[digit]=(unsigned char)digitInput-48;
			 digit++;

			 printf("%d",digitInput-48);
			   
		   }
		   if (digitInput==13)  { digitn=digitArray[0]; break; }
	   }
   }

   switch(digit)
   {
       case 0:
       case 1:
            digitn=digitArray[0]*1 ;
	   break;

       case 2:
            digitn= digitArray[1]*1  +digitArray[0]*10  ;
	   break;

       case 3:
            digitn=  digitArray[2]*1+digitArray[1]*10 +digitArray[0]*100  ;
	   break;
             
       case 4:
             digitn=digitArray[3]*1+digitArray[2]*10+digitArray[1]*100+digitArray[0]*1000 ;
	   break;

       case 5:
             digitn=digitArray[4]*1+digitArray[3]*10+digitArray[2]*100+digitArray[1]*1000+digitArray[0]*10000 ;
	   break;

       case 6:
             digitn=digitArray[5]*1+digitArray[4]*10+digitArray[3]*100+digitArray[2]*1000+digitArray[1]*10000 
				   +digitArray[0]*100000;
	   break;


       case 7:
             digitn=digitArray[6]*1+digitArray[5]*10+digitArray[4]*100+digitArray[3]*1000+digitArray[2]*10000 
				   +digitArray[1]*100000 +digitArray[0]*1000000;
	   break;


       case 8:
             digitn=digitArray[7]*1+digitArray[6]*10+digitArray[5]*100+digitArray[4]*1000+digitArray[3]*10000 
				   +digitArray[2]*100000 +digitArray[1]*1000000+digitArray[0]*10000000;
	   break;

       case 9:
             digitn=digitArray[8]*1+digitArray[7]*10+digitArray[6]*100+digitArray[5]*1000+digitArray[4]*10000 
				   +digitArray[3]*100000 +digitArray[2]*1000000+digitArray[1]*10000000 +digitArray[0]*100000000;
	   break;


   }


  // if (digitInput!=13)  digitn=digitArray[3]*1+digitArray[2]*10+digitArray[1]*100+digitArray[0]*1000 ;
   printf("\n%i\n\n",digitn);
}

/*********************************
 *                               *
 ********************************/

int main()
{
	system("color 1F");     //Blue background       
   printf("DigitsIntoArrayComponents 3.1 by TopCoder  \n ");
   printf("Max Input is 8 Digits  ( . 99,999,999)  \n ");
   printf("\nInput Digits    >");
   getIntKey();
   
   printf("\ndigitArray[7]=%d \n",digitArray[7]);

   printf("digitArray[6]=%d \n",digitArray[6]);
   printf("digitArray[5]=%d \n",digitArray[5]);
   printf("digitArray[4]=%d \n",digitArray[4]);

   printf("digitArray[3]=%d \n",digitArray[3]);
   printf("digitArray[2]=%d \n",digitArray[2]);
   printf("digitArray[1]=%d \n",digitArray[1]);
   printf("digitArray[0]=%d \n",digitArray[0]);
   printf("\n%i\n\n",digitn);




	return 0;
}


...
GeneralRe: Now it is just clunky Pin
Luc Pattyn31-May-10 18:27
sitebuilderLuc Pattyn31-May-10 18:27 
AnswerRe: .:: How to convert a gotten int input into a char or string which each of their elements can be accessable separately? [C++] Pin
Aescleal31-May-10 10:29
Aescleal31-May-10 10:29 
QuestionRe: .:: How to convert a gotten int input into a char or string which each of their elements can be accessable separately? [C++] Pin
David Crow1-Jun-10 5:13
David Crow1-Jun-10 5:13 
QuestionBest way to open a HTML file from an URL Pin
Joschwenk66631-May-10 6:34
Joschwenk66631-May-10 6:34 
QuestionRe: Best way to open a HTML file from an URL Pin
David Crow31-May-10 7:13
David Crow31-May-10 7:13 
AnswerRe: Best way to open a HTML file from an URL Pin
Aescleal31-May-10 10:10
Aescleal31-May-10 10:10 
QuestionThe I/O Question of the network file or share file Pin
WanLiJun31-May-10 3:01
WanLiJun31-May-10 3:01 
AnswerRe: The I/O Question of the network file or share file Pin
KarstenK31-May-10 3:51
mveKarstenK31-May-10 3:51 
JokeRe: The I/O Question of the network file or share file Pin
Code-o-mat31-May-10 4:24
Code-o-mat31-May-10 4:24 
JokeRe: The I/O Question of the network file or share file Pin
KarstenK31-May-10 4:36
mveKarstenK31-May-10 4:36 
AnswerRe: The I/O Question of the network file or share file Pin
Aescleal31-May-10 9:59
Aescleal31-May-10 9:59 
Questionlibmms and ffmpeg Pin
rastaVnuce31-May-10 2:52
rastaVnuce31-May-10 2:52 
QuestionDLL Pin
john563231-May-10 0:03
john563231-May-10 0:03 
AnswerRe: DLL Pin
Cedric Moonen31-May-10 0:14
Cedric Moonen31-May-10 0:14 
GeneralRe: DLL Pin
john563231-May-10 0:39
john563231-May-10 0:39 
GeneralRe: DLL Pin
ThatsAlok31-May-10 1:47
ThatsAlok31-May-10 1:47 
AnswerRe: DLL Pin
ThatsAlok31-May-10 1:13
ThatsAlok31-May-10 1:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.