insert
Code:
const airplane airplaneTypes[3] = {
{.type = "737" ,.destinations = "Larnaca,Athens,Budapest,Zurich,London,Paris,Rome"},
{.type = "747" ,.destinations = "London,New York,Bangkok"},
{.type = "787" ,.destinations = "London,New York,Los Angeles,Hong Kong,Miami"}
};
int GetAirplaneType(const char *destination, char **pTotype)
{
char *n = NULL;
char *p;
int i;
char *pDestinationsList = NULL;
for (i = 0; i < 3; i=i+1)
{
pDestinationsList = (airplaneTypes[i].destinations);
p = strstr(pDestinationsList, destination);
if (p!=n )
{
printf("type print: %s\n", airplaneTypes[i].type);
pTotype = &airplaneTypes[i].type;
printf("print of the pointer value inside the function: %s\n", pTotype);
return (0);
}
}
return (-1);
}
void main()
{
int i = 3;
char **ppp=NULL ;
const char *des = "New York";
i=GetAirplaneType(des, ppp);
printf("function returns: %d\n", i);
printf("print of the pointer value outside the function: %s\n", ppp);
}