Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

Can argument of sizeof operator have an expression?

Can I do following:

sizeof ( int * 3)


Thanks!
0
naseeam
Asked:
naseeam
  • 2
1 Solution
 
Infinity08Commented:
That wouldn't make sense, because you're trying to multiply a type with a value.

Maybe you meant :

        sizeof(int) * 3

?
0
 
naseeamAuthor Commented:
You are correct!   I appreciate that!
0
 
naseeamAuthor Commented:
Very fast response.  Exactly what I needed.
0
 
evilrixSenior Software Engineer (Avast)Commented:
Although something like this should work...

sizeof ( 3 * 6 );

...since the result of 3 * 6 (both of implicit type int) is of type int thus the sizeof will return the size of the result type, which is an int.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now