Question: Given the following function, char * GetString ( std::istream& is ) { char str [ 2 5 5 ] ; is > > str; return

Given the following function,
char* GetString(std::istream& is){
char str[255];
is >> str;
return str;
}
what's wrong with GetString's definition?
A pointer to an array cannot be returned by any function.
An array's name can never be used to initialize a pointer.
The address of stack memory associated with a local variable is returned.
The return type must be char& instead of char* for GetString to compile.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!