left shift operator - qsn

  • Thread starter aliasger.jaffer
  • Start date
A

aliasger.jaffer

Hi,

I have an array A[10] of type short, and I want to left shift the value
in index 0 by four. I tried the following statement:

A[0] << = 4;

Unfortunately, I get the following error when I try to compile:
-- expected primary-expression before '=' token.

Any ideas/suggestions what i'm missing or doing wrong?

Thanks!

Ali
 
F

Frederick Gotham

posted:
A[0] << = 4;

Get rid of the space between << and =.

A[0] <<= 4;

Beware of integer promotion when playing around with anything smaller than an
int.
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top