hi everybody,
i've got a problem with a little thing.
// the declaration
int a= 32 ;
how do i get the ascii-character for the number wich is in the variable a? ???
thx
cd
In this case the character to display is a blank space. BTW, keep in mind that there are other ASCII characters which are non-printable, incidentally the range 0-31.
Oh ok didn't knew that. but just in case for another ascii-character like 75 int a=75;
and i wanna convert that one to an ascii-character is there a winapi function oder a usual library function wich i can use for it ?
and here just another question to it.
when i use a char array with values like that :
char *x={ Aa01 , Bb02 } ;
is a array like that :
char x[8];
equeal to that :
char x[8]={ Aa01, Bb02 }; = = char x[0]=A , x[1]=a , x[2]=0 , x[3]=1 , x[4]=B , x[5]=b , x[6]=0 , x[7]=2 x[8]='\0';
or are only the first two arrays with the values declared :
char x[0]= Aa01 , x[1]= Bb02;
i only wanna knew or get a correction of my thoughts - help is really appreciated - thx.
later
cd
Quote from: cd on June 16, 2007, 11:52:44 AM
Oh ok didn't knew that. but just in case for another ascii-character like 75 int a=75;
and i wanna convert that one to an ascii-character is there a winapi function oder a usual library function wich i can use for it ?
If you want to know which character is stored in a you can print it with
printf("%c", a);
[\code]
[quote author=cd link=topic=2206.msg8286#msg8286 date=1181987564]
and here just another question to it.
when i use a char array with values like that :
[code]
char *x={ Aa01 , Bb02 } ;
[/quote]
This code will not create an array.
To create an array you will need something like this:
char x[][] = {"Aa01", "Bb02"};
printf("%s\n", x[0]); //the output should be Aa01
printf("%s\n", x[1]); //the output should be Bb02
Quote from: cd on June 16, 2007, 11:52:44 AM
is a array like that :
char x[8];
equeal to that :
char x[8]={ Aa01, Bb02 }; = = char x[0]=A , x[1]=a , x[2]=0 , x[3]=1 , x[4]=B , x[5]=b , x[6]=0 , x[7]=2 x[8]='\0';
for this the array-size must be 9, because you have 2 times 4 characters and the endig zero.
if you want to store this kind of text in your array, you need some code like this:
char x[9];
strcpy(x, "Aa01"); // this will copy the string "Aa01" to x
strcat(x, "Bb02"); // this will merge the string "Bb02" to the string x
printf("%s\n", x); // You will get the output Aa01Bb01
I hope this can help you. ;)
[/code]
you helped me alot. yes, wright my declaration was just a pointer not a character array and many thanks to solve the question with the integer array.i wasn't sure if i have to cast the type of character or just to use the %c in the printf function , thank you very much.