jayapal said:
Hi
the scenario is like this:
func()
{
...
...
char *p= (char *)&str[0];
while (p)
*++p=='$' ? break
*p != ' ' ? return error : )
....
....
}
can i use conditional operator like these
As at least one other person has said, no. And even if you /could/,
you couldn't write what you wrote, because there's nothing after
the second `:`. And even if you could do /that/, what exactly is
this loop supposed to accomplish? It /looks/ like (fx:emulate) it
skips the first character [if any] and then skips spaces and
either returns the error value if it's not at $-or-eos, or
falls through pointing at $-or-eos.
If so, I would have thought:
char *p = str; /* suspect the casting and indexing useless */
if (*p) p += 1;
while (*p == ' ') p += 1;
if (*p == '$') { whatever } else return error;
was more transparent. (I have a stylistic preference away from using
++ when the result isn't consumed; feel free to replace `p += 1` by
`p++` in the above if you have the reverse preference.)