trying to pass a string

hey guys,

I have a function that I need to pass something like this to:

function(set=a);

so the "set=" part is always the same, but I'm getting the "a" part in a for loop.

so the calls would be in a loop and would end up doing:

function(set=a);
function(set=b);
function(set=c);
etc.....

So how can I pass this to a for loop?

for ( i=0; i< setlist; i++) {
function(???);
}

I can't figure out how to pass in "set=[i]" without it treating the [i]literally.

Thanks
Annie

Are you really passing a value to the function as "set=a"? Or are you going to be using the variable "set" in your function to hold the value that you are sending in to it (the values being a,b,c and so on)?

Also, you mention that you are getting the "a part in a for loop". Does this mean that the variables are stored in an array?

I can give you an answer based on the above two assumptions:

function(variable_type set) {

/*do processing here*/

}
.
.
for(i=0;i<setlist;i++) {
function(some_array);
}
.
.

If this is not what you are looking for, you need to describe the problem better or post some code.

Hi sorry I wasn't clear.

I'm actually want to pass the string "set=a", "set=b", "set=c", etc....to the function. The "set=" part always stays the same but a, b, c...etc. change which is the part I can't figure out how to deal with.

so I would so something like:

function("set=a");

and then function is:

function(char *string) {

printf\("string is %s\\n", string\);

}

/* added datatype to "function" */
#include <stdlib.h>

void function(char *string) 
{
    printf("string is %s\n", string);
}
int main(void)
{	
    char value='a';
    char tmp[24]={0x0};
    int i=0;
    /* loop thru all 26 lowercase letters */
    for(value='a', i=0;i<26;i++)
    {
        sprintf(tmp,"set=%c",value++);
        function(tmp);
    }
    return 0;
}

thanks so much! that is perfect.