Skip to content

Instantly share code, notes, and snippets.

View itczl22's full-sized avatar
👏
listening

itczl22

👏
listening
View GitHub Profile
@itczl22
itczl22 / uninitialized-local-variable.c
Last active November 5, 2016 07:52
未初始化的局部变量
#include<stdio.h>
void foo(void) {
int tmp;
printf("%d\n", tmp);
tmp = 999;
}
int main() {
foo(); // 0
@itczl22
itczl22 / align-fill_out.c
Last active October 30, 2016 08:10
地址的对齐补齐
#include<stdio.h>
int main() {
char ch = 8; // 1 + 3
int it = 9; // 4 + 4
int* ptr = &it; // 8
printf("%p\n%p\n%p\n\n", &ch, &it, &ptr);
typedef struct {
short sit; // 2 + 6
@itczl22
itczl22 / big-little-endian.c
Last active October 30, 2016 08:11
大端小端存储
#include <stdio.h>
int main(void) {
// 储存方式的判断
unsigned int a = 0x12345678;
const char* buf = (char*)&a;
printf("%x\n%x\n", buf[0], buf[3]);
// 78 12, 所以是小端存储
const char* str = "12345678";
@itczl22
itczl22 / go-cmd-install.sh
Created July 4, 2016 05:09
Install Go and common cmd tools.
#!/bin/bash
TMP=`pwd`/go-cmd-`date +%s`
GOX=src/golang.org/x
mkdir -p $TMP/$GOX
cd $TMP/$GOX
git clone https://github.com/golang/tools.git
git clone https://github.com/golang/net.git