Significance of using + before function calls.
Hi List,
i have seen a code snippet which starts with + symbol,
+system("ls -l");
what is the significance of using + symbol before system.
i also tried using + before printf ,, like +printf("Some text"); and it is compiling and working tooo,,
Can somebody clarify wht does that + signify??
Thank You.
-Vamsi
Quoted 4 lines · Vamsi
Hi List,
i have seen a code snippet which starts with + symbol,
Quoted 8 lines
+system("ls -l");
what is the significance of using + symbol before system.
i also tried using + before printf ,, like +printf("Some text"); and it is compiling and working tooo,,
Can somebody clarify wht does that + signify??
The unary plus operator returns the value of an expression. Neither the unary plus nor unary minus operators produce lvalues and is of limited use.
\Steve
Quoted 4 lines · Steve Graegert
The unary plus operator returns the value of an expression. Neither the unary plus nor unary minus operators produce lvalues and is of limited use.
So what might be the intention of someone using it like the OP described? It doesn't make much sense, right?
Per Jessen
Quoted 8 lines · Per Jessen
Quoted 4 lines · Steve Graegert
The unary plus operator returns the value of an expression. Neither the unary plus nor unary minus operators produce lvalues and is of limited use.
So what might be the intention of someone using it like the OP described? It doesn't make much sense, right?
I suppose it's there for a clean implementation of operators in C. While the unary minus returns the negative of the operand the unary plus returns the value to avoid ambiguity, i.e. shall the unary plus return the positive of a negative operand, as the unary minus does? IMHO, not a result I'd expect.
\Steve
The placement of '+' or '-' before the function call is performing a unary operator on the return value of the function.
Quoted 20 lines · Vamsi
Hi List,
i have seen a code snippet which starts with + symbol,
+system("ls -l");
what is the significance of using + symbol before system.
i also tried using + before printf ,, like +printf("Some text"); and it is compiling and working tooo,,
Can somebody clarify wht does that + signify??
Thank You.
(quoted diff) +0
-2-Vamsi -To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Joel M. Pareja
The placement of '+' or '-' before the function call is performing a unary operator on the return value of the function.
does it server any purpose ? , unary '+' operator will not have any significance effect on the return value
-Vamsi
Quoted 24 lines
Quoted 20 lines · Vamsi
Hi List,
i have seen a code snippet which starts with + symbol,
+system("ls -l");
what is the significance of using + symbol before system.
i also tried using + before printf ,, like +printf("Some text"); and it is compiling and working tooo,,
Can somebody clarify wht does that + signify??
Thank You.
(quoted diff) +0
-2-Vamsi -To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
That must be a typographical error.
Because '+' does nothing to the return value of the function. Also because there is no lvalue in the expression.
But with '-', there is an effect.
int dummy_func() { return 5; }
int num = -dummy_func();
As a result, num will be '-5'.
Quoted 39 lines · Vamsi
Quoted 2 lines · Joel M. Pareja
The placement of '+' or '-' before the function call is performing a unary operator on the return value of the function.
does it server any purpose ? , unary '+' operator will not have any significance effect on the return value
-Vamsi
Quoted 15 lines
Quoted 12 lines · Vamsi
Hi List,
i have seen a code snippet which starts with + symbol,
+system("ls -l");
what is the significance of using + symbol before system.
i also tried using + before printf ,, like +printf("Some text"); and it is compiling and working tooo,,
Can somebody clarify wht does that + signify??
Quoted 9 lines
Quoted 8 lines
Thank You.
(quoted diff) +0
-2-Vamsi -To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · Vamsi
i have seen a code snippet which starts with + symbol,
+system("ls -l");
I suspect that the "code snippet" in question comes from the output of "diff -u", and the + is part of the diff syntax, not part of the code.
Signature · 1 line
Glynn Clements <[email protected]>
Quoted 4 lines · Glynn Clements
Vamsi wrote:
Quoted 11 lines
Quoted 5 lines
i have seen a code snippet which starts with + symbol,
+system("ls -l");
I suspect that the "code snippet" in question comes from the output of "diff -u", and the + is part of the diff syntax, not part of the code.
No, i verified it is not a patch, or the output of diff.
Thank You.
Hello,
Vamsi napsal(a):
Quoted 1 line
Can somebody clarify wht does that + signify??
It suppresses the warning about ignored returned value returned by splint, for example.
Signature · 8 lines
.--------- Tomáš Janoušek a.k.a. Liskni_si ---------. : NOMI team, developer, http://tomi.nomi.cz/ [email protected] : ' JID:[email protected], ICQ#161807083, tel:+420608876277 ' - To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html