How to sort

Thread Starter

learneros

Joined Nov 2, 2007
14
I have a char buffer which contains intergers.I want to sort them.Do i need to convert this char buffer into interger.And is there any sorting function available in C or do i need to write my onw sorting code.If there is sorting function available then wat is it and how can i use it ?
 

Thread Starter

learneros

Joined Nov 2, 2007
14
Another thing is how can i convert char *array into int array.Actually i want to search an integer in that array so for tht i need to conver char array into int array.
 

Thread Starter

learneros

Joined Nov 2, 2007
14
alright i m left with one last problem of my work.As i mentioned before im passing two arguments
in command line.One is file name and second is a numeric value.In my program i get this numeric
value as it is like if i enter 7 it appears as 7 in program.The problem is when i read text
file value and there is 7 in tht file too,as i get it in char buffer and when i display it,it
appears as 55 which i think 7's ASCII equivalent.I want to make comparison between these two,how can
i do it.How can i make 7 which is there in 7 to apee
 

RiJoRI

Joined Aug 15, 2007
536
yes, 55 is ASCII '7'.
The easiest way to convert an ASCII decimal number in C is:

Num = Num - '0';

or

Num -= '0';

Checks for and guards against non-decimal (0-9) digits / characters is up to you.

--Rich
 
Top