HOW WOULD THIS FUNCTION BE WRITTEN IN C++:
Private Function CBinary(ByVal dec as integer) as String
dim x as integer
CBinary = ""
For x = 0 to 7
if dec and 2^x then
CBinary = "1" & CBinary
else
CBinary = "0" & CBinary
end if
Next x
End Function
WHAT ABOUT THIS ONE:
Private Function CDecimal(ByVal bin as String) as Integer
dim x as Integer
for x=0 to (len(bin)-1)
If Mid(bin, Len(bin) - x, 1) = "1" Then
CDecimal = CDecimal + (2^x)
End If
Next x
End Function
How would i convert these vb functions to correct c++ functions? Thanx in advance.
![]()




Reply With Quote