(u_char *)
-
hi there, i need to send the decimal number "2" as a parameter to a function, but the method passes this parameter as a (u_char *). how can i stop this number from being converted to its ascii value of 50 when passing it through the parameter. i can't send the ascii value of "2", as this is defined as STX in ascii table. ian dineen
-
hi there, i need to send the decimal number "2" as a parameter to a function, but the method passes this parameter as a (u_char *). how can i stop this number from being converted to its ascii value of 50 when passing it through the parameter. i can't send the ascii value of "2", as this is defined as STX in ascii table. ian dineen
"2" is not a number but a C-Style null terminated string (actually, an array of two chars :
{ '2', '\0' }
.idineen wrote:
how can i stop this number from being converted to its ascii value of 50 when passing it through the parameter.
can you show us a piece of the code by which you call the function, and how the function uses this parameter too ?? i'm quite sure you don't use it properly.
-
"2" is not a number but a C-Style null terminated string (actually, an array of two chars :
{ '2', '\0' }
.idineen wrote:
how can i stop this number from being converted to its ascii value of 50 when passing it through the parameter.
can you show us a piece of the code by which you call the function, and how the function uses this parameter too ?? i'm quite sure you don't use it properly.
the code below is used to put a snmp object id into a pdu packet along with 3 parameters. the third parameter is used by the program to identify that the paramter is interrupted as a integer. the 4th parameter "test" is the number that i want to pass, this parameter is of type "(u_char *)" and the last is the length of the string. snmp_pdu_add_variable(pdu, oid, oid_length, ASN_INTEGER , test, strlen(test));// thanks ian
-
the code below is used to put a snmp object id into a pdu packet along with 3 parameters. the third parameter is used by the program to identify that the paramter is interrupted as a integer. the 4th parameter "test" is the number that i want to pass, this parameter is of type "(u_char *)" and the last is the length of the string. snmp_pdu_add_variable(pdu, oid, oid_length, ASN_INTEGER , test, strlen(test));// thanks ian
Hi Idineen: Do you have access to the source code of snmp_pdu_add_variable? It could be that all variables are passed in as u_char*, then because of ASN_INTEGER, that function has code to convert it to an integer from the string value in test.
-
the code below is used to put a snmp object id into a pdu packet along with 3 parameters. the third parameter is used by the program to identify that the paramter is interrupted as a integer. the 4th parameter "test" is the number that i want to pass, this parameter is of type "(u_char *)" and the last is the length of the string. snmp_pdu_add_variable(pdu, oid, oid_length, ASN_INTEGER , test, strlen(test));// thanks ian
Try this:
int test = 2;
snmp_pdu_add_variable(pdu, oid, oid_length, ASN_INTEGER, reinterpret_cast<u_char*>(&test), sizeof(test));Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"