Results 1 to 4 of 4
I am developing an application to receive data using UDP socket.
My data may be in the form 123ABcD123
I face problem in converting a decimal number(ANSI equivalent of a ...
- 04-25-2008 #1Just Joined!
- Join Date
- Jun 2007
- Posts
- 7
need to read a from a socket
I am developing an application to receive data using UDP socket.
My data may be in the form 123ABcD123
I face problem in converting a decimal number(ANSI equivalent of a char) to its correspoding char...?
Like::: 65 stands for A,66 stands for B
i have a pointer to array of int containing :
65,66,67,68
which stands for
A,B,C,D
Is there any function which can convert those dec to char in C language ?
P.s) I cannot use itoa() because my gcc compiler states that it is not defined even after i have included stdlib.h
Is there someone who can help me in this...
Any help would be highly appreciated...
thank you...
- 04-25-2008 #2
Well simply define it then!
That is: A char can be a character (8 or 7 bits), an unsigned integer (8 bits) or signed integer (7 bits) of data or a simple boolean value in C -->> you get to define its use OK.
In the header file you would do sometime like.
unsigned char Mine // This defines Mine as a unsigned char of 8 bits.
On most systems unsigned int of 8 bits == character BUT it is NOT guarenteed so hence your got to do your own definitions.
you then would Initialize it in the main program like:
Mine = 0x60; // That is hex as in 11000000 binary
then you can usefully use the itoa(Mine) and atoi(Mine) functions, as they all operate on the defined bit size you defined in the header file. Understand!!
I suspect you need to do a lot more RTFM (Read The F&^&^^@ Manual) before you will venture further.
Enjoy
- 04-25-2008 #3Just Joined!
- Join Date
- Mar 2008
- Posts
- 23
hi
1. as u have numbers 65,66,.....if u want to print them u use %d in c isn't? but if u use %c it will print its corresponding ASCII character which might be A,B,C....
2. gcc says that stlib.h is not defined. make sure that it's defined by including it to ur source file , check if g++ is installed,sometimes gcc might be installed but g++ not.
Good luck
- 04-30-2008 #4Just Joined!
- Join Date
- Jun 2007
- Posts
- 7
Thanks for all those replied. I have solved the problem.


Reply With Quote