wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> cs >> C Programming
(Message started by: Robert09 on Sep 17th, 2015, 1:04am)

Title: C Programming
Post by Robert09 on Sep 17th, 2015, 1:04am
Hi all. I have one question about C programming. Is it possible to multiply a char and an int?

char hash = '#'
int hashNumber = 3

hash * hashNumber

Thanks

Title: Re: C Programming
Post by towr on Sep 17th, 2015, 10:10pm
The easiest way to find out is to try.
C is quite happy to interpret a char as an 8-bit integer, so yeah, multiplying them is not a problem. Whether the result is what you'd expect is another question; the result will be different than if you try the same thing in python.

C: http://goo.gl/RRsV1V
Python: http://goo.gl/cvRfue



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board