dimanche 19 avril 2015

how to pass an integer to a function and return a string

I am trying to write a function that passes an int as a parameter and returns a string which is generated from a mysql query. I would one I have that working like to be able to pass a number of parameters (1 int and 2 chars) and have returned 3 strings, I guess those will require a struct and pointers but i'll start with the simple stuff.. crawl first..run later :)


Here is the code I have written I have removed the function but it's failing on compile at the line



retString = strFunction(int Value);


with the error:



warning: assignment makes pointer from integer without a cast [enabled by default]


I can post the full code if required..


Many Thanks in advance.



int main(int argc, char *argv[])
{

char *retString;
retString = strFunction(int Value);
printf("The Return string is: %s", retString);
Exit (0);

}


char *strFunction(int value)
{

perform code here using value;
Return retString;

}

Aucun commentaire:

Enregistrer un commentaire