[newbie]:function returns a pointer to a string

U

uy do

Hi,
I see a function but I dont white understand a few things. So please help me
to clear it out.
The code is as follow
-------------
//global variable
char buf[32768];

char * myfunc(s1)
char *s1;
{
//definition of the function
return (buf);
}
 
T

Tristan Miller

Greetings.

char * myfunc(s1)
char *s1;
{
//definition of the function
return (buf);
}

This is old-style (K&R) C, which predates the ANSI/ISO standards. Nowadays
the equivalent syntax you suggested is preferred, and all modern compilers
support it.

This question is also answered in the FAQ.
 
J

Joona I Palaste

uy do said:
Hi,
I see a function but I dont white understand a few things. So please help me
to clear it out.
The code is as follow
char * myfunc(s1)
char *s1;
{
//definition of the function
return (buf);
}

It's an old K&R style definition. It's more or less the same. Not
exactly the same though - the way it handles argument promotions
differs. I don't remember exactly how it differs. K&R style definitions
are still valid in standard C, but deprecated. <OT>C++ does not allow
K&R style definitions.</OT>
 
U

uy do

Thanks,
~Uy
Joona I Palaste said:
It's an old K&R style definition. It's more or less the same. Not
exactly the same though - the way it handles argument promotions
differs. I don't remember exactly how it differs. K&R style definitions
are still valid in standard C, but deprecated. <OT>C++ does not allow
K&R style definitions.</OT>

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"C++ looks like line noise."
- Fred L. Baube III
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top