KazIT
asked on
: warning C4172: returning address of local variable or temporary
I get this warning on the following piece of code. Can anyone tell me how to stop it please?
//converts the string data type to char array
char* stringToChar(string temp)
{
char arr[BIRD_SIZE];
int i=0; while(temp[i]!='\0')
{
arr[i]=temp[i]; i++; } arr[i]='\0'; return(arr);
}
//converts the string data type to char array
char* stringToChar(string temp)
{
char arr[BIRD_SIZE];
int i=0; while(temp[i]!='\0')
{
arr[i]=temp[i]; i++; } arr[i]='\0'; return(arr);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you Indrawati
Kaz
Kaz
ASKER
char* stringToChar(string temp)
{
char arr[BIRD_SIZE];
int i=0;
while(temp[i]!='\0')
{
arr[i]=temp[i];
i++;
}
arr[i]='\0';
return(arr);
}