多年没用C语言了。近日用R语言编程时因有太多循环,只好用C写个扩展模块,一时竟不知怎么动手了。在多种语言中,单引号和双引号是可以等同使用的。因键入双引号要比单引号多按一SHIFT键,我偏好单引号。在用printf显示字符串, 我就自然地用上了单引号来定义格式串,哪知用gcc编译时竟出错了:
[xxia@xxq 4Mike]$ gcc pvc.c
pvc.c:179:9: warning: multi-character character constant
pvc.c: In function ‘pv_concord_more’:
pvc.c:179: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
pvc.c:184:9: warning: multi-character character constant
pvc.c:184: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
pvc.c:229:9: warning: multi-character character constant
pvc.c:229: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
pvc.c:232:9: warning: multi-character character constant
pvc.c:232: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
[xxia@xxq 4Mike]$
改回双引号后,才顺利编译。
实在不记得C语言中单双引号的区别了,不知是当初没学好,还是搞忘了,抑或是gcc的一个特点?