char a[4] = {255,255,255,255}; strncpy( a, "ABC", 1 ); printf( "%x\n", 0x000000ff & a[1] ); strncpy( a, "ABC", 2 ); printf( "%x\n", 0x000000ff & a[1] ); lstrcpyn( a, "ABC", 2 ); printf( "%x\n", 0x000000ff & a[1] );
ff 42 0
#include "stdafx.h" #include <windows.h> #include <shlwapi.h> #include <stdio.h> #pragma comment( lib, "shlwapi.lib" ) int main( int argc, char *argv[] ) { char *a = "ABC1XYZ"; int pos; pos = StrCSpn( a, "1234568790" ); printf( "%d\n", pos ); return 0; }
#include "stdafx.h" #include <windows.h> #include <shlwapi.h> #include <stdio.h> #pragma comment( lib, "shlwapi.lib" ) int main( int argc, char *argv[] ) { char *a = "ABC1XYZ"; int pos; pos = StrSpn( a, "ABCXYZ" ); printf( "%d\n", pos ); return 0; }
#include "stdafx.h" #include <windows.h> #include <shlwapi.h> #include <stdio.h> #pragma comment( lib, "shlwapi.lib" ) int main( int argc, char *argv[] ) { char *a = "ABC1XYZ"; char *pos; pos = StrStr( a, "XY" ); printf( "%d\n", pos - a ); return 0; }
#include "stdafx.h" #include <windows.h> #include <shlwapi.h> #include <stdio.h> #pragma comment( lib, "shlwapi.lib" ) int main( int argc, char *argv[] ) { char a[20] = "aabbccX0Y0Z001122"; char *pos; StrTrim( a, "abc012" ); printf( "%s\n", a ); return 0; }