Anyone know a int to char func? (for a variadic func)
#1

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.
Reply
#2

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
Reply
#3

Appears as if it will work, can't believe i have never used that function before.

Thanks M8. +1
Reply
#4

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
Reply
#5

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?
Reply
#6

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
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)