Anyone know a int to char func? (for a variadic func) -
iggy1 - 16.04.2012
Hi, my problem is i need to copy a string from a variadic function. I will post an example of what i mean.
This code is obviously bugged i know that, it should make clear what i want to do though (i hope).
pawn Код:
foo( ... )
{
new
ch,
idx,
szBuffer[ 64 ],//this would be the query in my code
iArgs = numargs()
;
for( new i = 0; i < iArgs; ++i )
{
for( ;; )
{
szBuffer[ idx ] = getarg( i , idx );//how to turn this result into a char
if( szBuffer[ idx ] == EOS )
{
idx = 0;
break;
}
idx++;
}
}
}
The real reason i want to know how to do this is; I'm creating a function that builds SQL queries.
Re: Anyone know a int to char func? (for a variadic func) -
aRoach - 16.04.2012
valstr ?
Maybe do a valstrEx:
pawn Код:
valstrEx( value, bool:pack = false )
{
new p_Str[ 500 ];
valstr( p_Str, value, pack );
return 1;
}
Sorry if I did not understand
Re: Anyone know a int to char func? (for a variadic func) -
iggy1 - 16.04.2012
Appears as if it will work, can't believe i have never used that function before.
Thanks M8. +1
Re: Anyone know a int to char func? (for a variadic func) -
Joe Staff - 16.04.2012
You want to turn a single integer into a single character?
If so, as an integer it will automatically translate into a character.
pawn Код:
printf("Printing: %c - %c",'A',65);
should print
Printing: A - A
Re: Anyone know a int to char func? (for a variadic func) -
iggy1 - 16.04.2012
Quote:
Originally Posted by Joe Staff
You want to turn a single integer into a single character?
If so, as an integer it will automatically translate into a character.
pawn Код:
printf("Printing: %c - %c",'A',65);
should print
Printing: A - A
|
Thanks for the reply, if you could look at my first post this line "szBuffer[ idx ] = getarg( i , idx );"
Would i be able to use "szBuffer" as a normal string?
Re: Anyone know a int to char func? (for a variadic func) -
Joe Staff - 16.04.2012
If you're expecting "getarg( i , idx);" to return a single letter/character, then yes.
pawn Код:
string[5];
string="test";
print(string);
string[0]=116;
string[1]=101;
string[2]=115;
string[3]=116;
string[4]=EOS;
print(string);
Should return
test
test
Re: Anyone know a int to char func? (for a variadic func) -
iggy1 - 16.04.2012
Quote:
Originally Posted by Joe Staff
If you're expecting "getarg( i , idx);" to return a single letter/character, then yes.
|
Thanks M8 for the quick reply another +1
I feel like a wolly for not making a simple test like that myself.
PROBLEM SOLVED.