puts的功能更加单一,只能输出字符串:printf的功能更加广,可以格式化数据,输出多种类型的数据. puts()函数用来向标准输出设备(屏幕)写字符串并换行. 调用方式为puts(string):其中,string是字符串字符(字符串数组名或字符串指针). # include <stdio.h> int main(){ string a = "happy new year!"; puts(string); return 0; } printf()函数是格式化输出函数,一…
C-C++到底支不支持VLA以及两种语言中const的区别 到底支不支持VLA VLA就是variable-length array,也就是变长数组. 最近写程序的时候无意间发现,gcc中竟然支持下面这种写法: int n = 10; int a[n]; 注意上面的语句是在函数内部写的,也就是n和a都是自动变量. 当时十分疑惑,C语言中数组的长度不应该是常量或常量表达式吗?为什么变量也可以.我将代码在VC中跑了一下,发现编译出错,提示数组的大小未知,说明VC中是不支持VLA的. 那既然有的编译器…
Go语言中byte和rune实质上就是uint8和int32类型.byte用来强调数据是raw data,而不是数字:而rune用来表示Unicode的code point.参考规范: uint8 the set of all unsigned 8-bit integers (0 to 255) int32 the set of all signed 32-bit integers (-2147483648 to 2147483647) byte alias for uint8 rune ali…
Go语言中new跟make是内置函数,主要用来创建分配类型内存. new( ) new(T)创建一个没有任何数据的类型为T的实例,并返回该实例的指针: 源码解析 func new func new(Type) *Type The new built-in function allocates memory. The first argument is a type, not a value, and the value returned is a pointer to a newly alloc…
原文呢:http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration.strict Only valid typehint for boolean is bool. As per documentation boolean isn't recognized as alias of bool in typehints. Instead it is treated as class name…