Click to See Complete Forum and Search --> : returning stuff


EscapeCharacter
09-20-2001, 11:48 AM
ive noticed alot of functions are written like this,
char *funcname(whatever)

does this mean it returns a char pointer?

TheLinuxDuck
09-20-2001, 12:00 PM
Yessir. An example would be if you created a function to handle the allocation of a buffer, or the like:


char *makeBuffer(const int size)
{
char *tempPtr;
tempPtr=(char *)malloc(size);
if(tempPtr==NULL)
perror("makeBuffer: alloc failed");
return tempPtr;
}

and

int main(void)
{
char *newBuffer;
newBuffer=makeBuffer(4096);
if(newBuffer==NULL) return 1;

/* ... yada yada yada ... */
free(newBuffer);
return 0;
}


Pointers rock! (^=