一.何谓可变参数 int printf( const char* format, ...); 这是使用过C语言的人所再熟悉不过的printf函数原型,它的参数中就有固定参数format和可变参数(用"-"表示). 而我们又可以用各种方式来调用printf,如: printf( "%d ",value); printf( "%s ",str); printf( "the number is %d ,string is:%s ",
今天笔试的时候遇到一个考察C语言scanf函数的题目 int x; float y; scanf("%3d%f",&x,&y); // input 123456 678 enter and then what's the value of x and y printf("%d %f",x,y); 程序的运行结果是: 123 456.0000000 看来还是自己对scanf函数不是非常了解,如今看看scanf函数的描写叙述例如以下: 格式:既字符串序列
“用C语言写一个函数测试当前机器的大小端模式”是一个经典的笔试题,如下使用两种方式进行解答: 1. 用union来测试机器的大小端 #include <stdio.h> union test { int a; char b; }; int endian_test(void) { union test t1; t1.a = ; return t1.b; } int main(void) { int i = endian_test(); ) { printf("is little end