1 #include <stdio.h> 2 #include <stdlib.h> 3 4 FILE *stdin; 5 FILE *stdout; 6 FILE *stderr; 7 _libc_init()8void _libc_init() 9 { 10 // 初始化标准流对应的文件描述符 11 stdin = malloc(sizeof(FILE)); 12 stdout = malloc(sizeof(FILE)); 13 stderr = malloc(sizeof(FILE)); 14 15 stdin->fd = 0; 16 stdout->fd = 1; 17 stderr->fd = 2; 18 }