摘要: 复习C++ Primer Plus 第5章时看到的一个知识点(此处已完全不记得了),若word是数组名,表达式:word == "mate" 的意义是?数组名是指针,也就是数组的地址,而双引号的寡不字符串常量同样是地址,所以,这个表达式不是判断两个字符串是否相同,而是查看它们是否存储在相同的地址上。当然答案是否定的,即使word数组的字符串也是“mate”。《C++ Primer Plus》 P127 阅读全文
posted @ 2011-10-25 23:21 jeff_nie 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 1. 将字符存入文件: logfile = open('/tmp/mylog.txt', 'a') # 以追加方式打开/tmp/mylog.txt文件,此时logfile类似于C语言的文件指针 print >> logfile, 'Fatal error: invalid input!' # 将'Fatal error: invalid input' 存入logfile 中 cat /tmp/mylog.txt # 显示/tmp/mylog.txt 内容2. 将输入的字符赋值给变量: name = raw_input( 阅读全文
posted @ 2011-10-25 18:19 jeff_nie 阅读(286) 评论(0) 推荐(0) 编辑