Have macro 'return' a value
Posted
by bobobobo
on Stack Overflow
See other posts from Stack Overflow
or by bobobobo
Published on 2010-04-20T22:34:53Z
Indexed on
2010/04/20
22:43 UTC
Read the original article
Hit count: 154
I'm using a macro and I think it works fine -
#define CStrNullLastNL(str) {char* nl=strrchr(str,'\n'); if(nl){*nl=0;}}
So it works to zero out the last newline in a string, really its used to chop off the linebreak when it gets left on by fgets.
So, I'm wondering if I can "return" a value from the macro, so it can be called like
func( CStrNullLastNL( cstr ) ) ;
Or will I have to write a function
© Stack Overflow or respective owner