Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-10-2008
Member
 
Join Date: May 2008
Posts: 35
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; 
);
Reply With Quote
  #2  
Old 15-10-2008
Member
 
Join Date: May 2008
Posts: 2,008
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?
Reply With Quote
  #3  
Old 15-10-2008
Member
 
Join Date: May 2008
Posts: 2,293
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Viewing items that are on a table and not in Edi (SQL)"
Thread Thread Starter Forum Replies Last Post
Unable to work with table columns in opera browser when the table has wide layout Janya Technology & Internet 5 27-08-2011 10:53 AM
When searching in Windows 7 I get a list of group headers for items but not the items chyarte Operating Systems 3 17-01-2011 12:58 PM
Link a Table to another Table to Drop Down In Main Table himeshRES Windows Software 6 11-12-2010 02:01 PM
Colonizing a table of employees from a table of applicants in Microsoft Access laplapye Windows Software 4 30-11-2010 03:01 AM
x200t multitouch screen viewing angles and portrait viewing Mycenaen Portable Devices 6 17-09-2010 06:34 AM


All times are GMT +5.5. The time now is 05:22 AM.