遇见YY

导航

 
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
    int buf_size = 1024;
    uint8_t *buf = malloc(buf_size);
    *(uint32_t *) (buf + 4) = 18010;
    strcpy((char *) buf + 8, "Hello World!");
    printf("buf + 0:%d\n", *(uint32_t *)(buf + 0));
    printf("buf + 4:%d\n", *(uint32_t *)(buf + 4));
    printf("buf + 8:%s\n", buf + 8);
    free(buf);
    return 0;
}

 

posted on 2020-10-07 20:54  一骑红尘妃子笑!  阅读(189)  评论(0编辑  收藏  举报