格式化输入/输出
#include <stdio.h>
int main(int AC, char **AV)
{
FILE *fd = fopen("data", "w+");
fprintf(fd, "%x%c", 0x41, '1');
fseek(fd, 0, SEEK_SET);
int n;
fscanf(fd, "%d", &n);
fseek(fd, 0, SEEK_SET);
char s[4];
int c = fread(s, 1, sizeof(s), fd);
s[c] = '\0';
printf("%d, %s\n", n, s);
fclose(fd);
getchar();
}
转自http://www.dutor.net/index.php/2010/10/format-stdio/

浙公网安备 33010602011771号