摘要: //version 1 while (cin.get(ch)) { if (ch == ' ') spaces++; if (ch == '\n') newlines++; } //version 2 while (cin.get(ch)) { if (ch == ' ') spaces++; el 阅读全文
posted @ 2016-10-22 21:03 King_KO 阅读(394) 评论(0) 推荐(0) 编辑
摘要: 例: struct inflatable{ char name[20]; float volume; double price;}; inflatable * ps = new inflatable; 当我们需要用指针来操作结构体内的变量时,要通过箭头来操作: 如:ps->price; 如果我们是使 阅读全文
posted @ 2016-10-19 20:03 King_KO 阅读(358) 评论(0) 推荐(0) 编辑
摘要: 例: char animal[20] = "bear"; char * ps; ps = animal; 在这种情况中,通过ps = animall赋值语句之后,并不会把数组animal的值赋值给ps,而是只是赋值地址。 可以通过语句cout << ps << endl;输出指针所指向的地址的值,所 阅读全文
posted @ 2016-10-19 19:34 King_KO 阅读(100) 评论(0) 推荐(0) 编辑
摘要: long* fellow; *fellow = 223323; 这样做是很危险的,因为没有给fellow赋地址,无法确定fellow所存的是何值,可能是任意值。不管值是什么,程序都将它解释为存储223323的地址。如果fellow的值碰巧为1200,并不是你想要的地址,这中错误可能会导致一些最隐匿、 阅读全文
posted @ 2016-10-17 17:03 King_KO 阅读(234) 评论(0) 推荐(0) 编辑