Link to home
Start Free TrialLog in
Avatar of KazIT
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);                              
}                                                                                    
Avatar of KazIT
KazIT

ASKER

//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
Avatar of Indrawati
Indrawati

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KazIT

ASKER

thank you Indrawati

Kaz