U
Uncle
I am an untrained hobbyist. Everything about programming I have learned
from the internet. Thank you all for your gracious support.
This is what I have:
#define CONST_CHAR 0
void some_func( char* arg, int len )
{
// stuff
}
Most times there is a character array sent as "arg", but sometimes I only
need to send a single character.
Don't laugh, I know this doesn't work:
void main( void )
{
some_func( (char*)CONST_CHAR, 1 );
}
This does, and it is what I'm doing now:
void main( void )
{
char array[1];
array[0] = CONST_CHAR;
some_func( array, 1 );
}
My questions are:
Is there a way to construct the arg that looks more like the first
non-working example? If there is, would it make any difference in not
having to allocate an array, ( albeit one byte, ) to send a single
character?
from the internet. Thank you all for your gracious support.
This is what I have:
#define CONST_CHAR 0
void some_func( char* arg, int len )
{
// stuff
}
Most times there is a character array sent as "arg", but sometimes I only
need to send a single character.
Don't laugh, I know this doesn't work:
void main( void )
{
some_func( (char*)CONST_CHAR, 1 );
}
This does, and it is what I'm doing now:
void main( void )
{
char array[1];
array[0] = CONST_CHAR;
some_func( array, 1 );
}
My questions are:
Is there a way to construct the arg that looks more like the first
non-working example? If there is, would it make any difference in not
having to allocate an array, ( albeit one byte, ) to send a single
character?