casting ints and floats to char*

Robert Angelino robert at nereid.jpl.nasa.gov
Thu Apr 25 10:10:47 AEST 1991


Hello C people,
	I'm trying to have a char* array point to different types, i.e
hold addresses of ints,floats, and longs.

I want to be able to do the following:

void has_to_be_done_this_way()
{
char *ptr[12];
int  i;
long j;
double p;

ptr[0] = &i;
ptr[1] = &j;
ptr[2] = &p;

sscanf(buf,"%2d %5ld %15lf",&(*ptr[0]),&(*ptr[1]),&(*ptr[2]));
}

I hope I'm conveying myself clearly--that's what I'm trying to do.

Does anyone have any suggestions??

thanks in advance

p.s. Please e-mail me directly.

-- 
    -     ------       -                              Robert Angelino
   | |   | ----  \    | |                             ms T-1704L
   | |   | |   \ |    | |                             4800 Oak Grove Drive
   | |   | | --  |    | |                             Pasadena, CA 91109
---| |   | | \__/     | |___                          robert at triton.jpl.nasa.gov
\____|et |_|ropulsion |_____\aboratory                (818) 354-9574



More information about the Comp.lang.c mailing list