The return type of the function as a string
The function returns the data type can be used as a string. However, one thing is noticeable, caller function value points to the garbage. For example:
char * funcX ()
{
char str [] = "A sample string";
return str;
}
Function at compile time the compiler does not have any errors in the data will not be shown to the caller function properly. The work function of time will keep the data stack, it will not be the end of the work function. Function so that the caller will receive an IP address, which will be garbage data points. The function returns the string that should be taken at the time. The caller of the function determines the required space can be sent kalda function. For example:
funcX (char * str)
{
strcpy (str, "String from funcX")
return st;
}
This function can be used. This function returns the address of the main str, so ptr data point does not have any garbage. Or it can be done without having to use the function myalaka kalda function. For example:
char * funcX ()
{
char * ptr;
ptr = malloc (32 * sizeof (char));
strcpy (ptr, "String from funcX");
return ptr;
.jpg)
No comments:
Post a Comment
No Samp