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
For a macro to “return a value”, the macro itself has to be an expression. Your macro is a statement block, which cannot evaluate to an expression.
You really ought to write an
inlinefunction. It will be just as fast and far more maintainable.