ij = ic: 0;

C

Chris Saunders

I was reading some C code and came across this:

ij = ic: 0;

ij and ic are of type int.

I assume that ij and ic are being assigned the value 0 but
I don't recall ever seeing this before.

Anyone know if this is proper?

Regards
Chris Saunders
 
K

Krishanu Debnath

Chris said:
I was reading some C code and came across this:

ij = ic: 0;

ij and ic are of type int.

I assume that ij and ic are being assigned the value 0 but
I don't recall ever seeing this before.

Anyone know if this is proper?

Regards
Chris Saunders
No, It is not. Did you mean ','/'=' instead of ':' ?

krishanu@meghna[86] cat nonsense.cxx
#include<stdio.h>

int main()
{
int ij = 0;
int ic = 0;
ij = ic: 0;
return 0;
}
krishanu@meghna[87] mc nonsense.cxx
nonsense.cxx: In function `int main()':
nonsense.cxx:7: parse error before `:' token
krishanu@meghna[88]


Krishanu
 
K

Keith Thompson

Chris Saunders said:
I was reading some C code and came across this:

ij = ic: 0;

ij and ic are of type int.

I assume that ij and ic are being assigned the value 0 but
I don't recall ever seeing this before.

No, you weren't reading some C code. :cool:}

What context did it appear in (just a few lines)? Are you sure that
was exactly what it said? If the ':' were a ';', it would be legal
(but not necessarily sensible).
 
A

Allan Bruce

No, you weren't reading some C code. :cool:}
What context did it appear in (just a few lines)? Are you sure that
was exactly what it said? If the ':' were a ';', it would be legal
(but not necessarily sensible).

or if it were
ij = ic? 5 : 0;
or similar, it would be valid
 
R

Richard Tobin

Chris Saunders said:
ij = ic: 0;

This is not syntactically correct. Is it perhaps part of some larger
conditional expression (that is, a use of the ternary a?b:c operator)?

-- Richard
 

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

No members online now.

Forum statistics

Threads
474,160
Messages
2,570,889
Members
47,421
Latest member
StacyTaver

Latest Threads

Top