#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char a[8] = { 31,32,33,61,62,63,34,35 }; char *s = malloc(9); char *str = s; memset(s,0,9); for (int i = 0; i < 8; i++) { *s = a[i]; s++; } printf("%s\n",str); return 0; }
#include <stdio.h> int main( void ) { char a[] = { 0x31, 0x32, 0x33, 0x61, 0x62, 0x63, 0x34, 0x35 }; printf( "%.*s\n", sizeof(a), a ); return 0; }