TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   Viewing items that are on a table and not in Edi (SQL) (http://forums.techarena.in/software-development/1055240.htm)

 beatnik_abx 15-10-2008 07:38 PM

Viewing items that are on a table and not in Edi (SQL)

My problem is that I want to do in a function C happens to me an integer less than 100 (ie two digits) to a string of two characters:

23 -> 23
5 -> 05

And more that I try, do not know how to do it. The truth is it was never my strong handling strings with C. So happened to me one way but I have problems with the function and, of course, the handling of characters for the return value, you get part of my code to see if I put help or should I go for another forms.

Code:

```char * pasarMinutos (int minutes) ( char length [3]; / * declare string of three characters who will be the maximum * / int first, second; length [3] = '\ 0'; / * put the character string at the end of the last position * / if (minutes> 9) / * if the digit is two numbers * / ( first = (int) (minutos/10); / * calculate the first number * / if (first == 1) / * and since I'm going aki putting the first character according to the num * / ( LENGTH [1] = "1"; ) else if (first == 2) ( LENGTH [1] = "2"; ) ............................................... else if (first == 9) ( LENGTH [1] = "9"; ) second = (min-first * 10); / * calculate the second num * / if (second == 1) / * and the same thing with the first q * / ( LENGTH [2] = "1"; ) else if (second == 2) ( LENGTH [2] = "2"; ) ...................................... ) else if (second == 9) ( LENGTH [2] = "9"; ) ) else / * if the number is only one-digit * / ( LENGTH [1] = "0" / * the first character will be a 0 * / second = minutes; / * and from aki ago as in the previous * / if (second == 1) ( LENGTH [2] = "1"; ) else if (second == 2) ( LENGTH [2] = "2"; ) .................................... else if (second == 9) ( LENGTH [2] = "9"; ) ) return length; );```

 Katty 15-10-2008 07:41 PM

I am new to this program but I think there's a function in stdlib.h that does that same item ()

Anyway I have been bitten curiosity and I have been thinking about the algorithm. This is what I get:
Code:

```itoa2 void (int num, char string []) ( char aux ='0 '; if (num == 0) ( string [0] = '\ 0'; ) else ( string [0] = (char) (aux + (num% 10)); itoa2 (num / 10, & (string [1])); ) )```
What you think?

 Zecho 15-10-2008 07:42 PM

I understand that what you want in this program here:

Code:

```int result, value; char characters [3] = ( "00 "};// this is only for you to put an end to the string result = valor/10; characters [0] = result +48 / / 48 is the decimal value of 0 in ascii, 30Hex resulting value% = 10; characters [1] = result +48 / / well as the values achieved in ascii```

 All times are GMT +5.5. The time now is 08:32 PM.