This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() { | |
char ch = 8; // 1 + 3 | |
int it = 9; // 4 + 4 | |
int* ptr = ⁢ // 8 | |
printf("%p\n%p\n%p\n\n", &ch, &it, &ptr); | |
typedef struct { | |
short sit; // 2 + 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 通过3个宏和一个类型实现: | |
* va_start va_arg va_end va_list | |
* 实现: | |
* 把参数在栈中的地址记录到va_list中, 通过一个确定参数first_num确定地址然后逐个读取值 | |
* 通常也会在对第一个参数进行一些特殊处理以方便函数的实现 | |
* 比如强制指定为参数个数、指定结束参数或者像printf一样使用格式占位符来 | |
* 参数是如何获取的, 为什么要指定第一个参数: | |
* 函数的调用的参数会进行压栈处理, 而对参数的压栈是从右到左进行压栈 | |
* 因此栈顶就是第一个有名参数, 而参数和参数之间存放是连续的 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
NewerOlder