Steve Church

passing fixed data and variables to function using pointers

Discussion created by Steve Church on Aug 2, 2007
Latest reply on Aug 2, 2007 by CompilerGuru
I have a number of predefined data strings and also a variable area which I wish to be accessed by a function which sends  the data bytes to an output routine.
I have assigned the fixed strings as
    const unsigned char string1[] = "This is string 1";
    const unsigned char string2[] = "And this is another string";

the variable is in
    unsigned char temp_store[256];

I am passing reference using
    size = sizeof(store1) -1;
    send_data_to_output(store1, size);    
    size = sizeof(temp_store) - 1;         //assume a NUL added to end of data as terminator
    send_data_to_output(temp_store, size)

the sending routine is defines as
    void send_data_to_output(unsigned char *pointer, unsigned char data_size)

 When ' temp_store' is passed it compiles ok but when I try to pass 'string1' for example it gives me an "Indirection to different types" error. I can see why its doing it as one is const and the other isnt. How do I get my routine to work with both constant and variable data? without having first to transfer the const data into a variable?