Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
beginsWith -- Check if Byte Array Begins with Byte SequenceDetermine if a byte array begins with a specific byte sequence. Downloads: MS Windows Visual C/C++ Libraries Linux/CentOS C/C++ Libraries MAC OS X C/C++ Libraries Solaris C/C++ Libraries C++ Builder Libraries #include <CkByteData.h> void ChilkatSample(void) { CkByteData zipData; CkByteData gifData; bool success; // Zip files begin with these 4 bytes: unsigned char zipBegin_bytes[] = { 0x50, 0x4B, 3, 4}; CkByteData zipBegin; zipBegin.append(zipBegin_bytes, 4); // GIF files begin with "GIF89", which is this byte sequence: unsigned char gifBegin_bytes[] = { 0x47, 0x49, 0x46, 0x38, 0x39}; CkByteData gifBegin; gifBegin.append(gifBegin_bytes, 5); success = zipData.loadFile("dude.zip"); if (success == true) { if (zipData.beginsWith(zipBegin)) { printf("Yes, this is a .zip archive!\n"); } else { printf("No, this is not a .zip archive.\n"); } } else { printf("Failed to load dude.zip\n"); } success = gifData.loadFile("dude.gif"); if (success == true) { if (gifData.beginsWith(gifBegin)) { printf("Yes, this is a GIF image!\n"); } else { printf("No, this is not a GIF image.\n"); } } else { printf("Failed to load dude.gif\n"); } } |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.