| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Converts a character string to an integer based on a bit pattern.
CtoBit( <cString> , <cBitPattern> ) --> nInteger
The function returns an integer value in the range of 0 to 65535.
| See also: | BitToC(), NtoC() |
| Category: | CT:NumBits , Numbers and Bits |
| Source: | ct\numconv.prg |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example displays results of CToBit() along with their
// binary representation.
PROCEDURE Main
? n := CToBit( "C", "ABCD" ) // result: 2
? NtoC( n, 2, 4, "0" ) // result: 0010
? n := CToBit( "ACD", "ABCD" ) // result: 11
? NtoC( n, 2, 4, "0" ) // result: 1101
RETURN
http://www.xHarbour.com