学习C++之父的最新姐妹作笔记2
????? 看了C++之父的最新作品也一段時間了,應該有半個月了,我是兩本書一起看的,結合起來看的,個人認為這樣看起來有助于理解,也看了好幾章了,沒有發現什么不大容易理解的地方,但有一個地方肯定是以前沒有注意到的或者說沒有接觸到的。好,廢話少說。
????? 在原理與實踐的71頁“蜂鳴提醒”“BLEEP”,這兩個詞我想有很多人不知道去如何實現,至少我不明白。經過查找MSDN c++之父要說的是這個函數Beep(--,--)
具體函數說明如下:
BOOL WINAPI Beep(__in DWORD dwFreq,__in DWORD dwDuration );Parameters
dwFreqThe frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
Windows?Me/98/95:??The Beep function ignores this parameter.The duration of the sound, in milliseconds.
Windows?Me/98/95:??The Beep function ignores this parameter.Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
當然這個函數要包含頭文件#include "windows.h"
Example:Beep( 750, 300 ); 下面是我將書上的試一試實現的程序: // BLEEP.cpp : 定義控制臺應用程序的入口點。 //#include "stdafx.h"//這里我就懶得加載c++之父給我們寫好的頭文件了std_lib_facilities.h 因為都是比較常見的頭文件 #include "windows.h" #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std;int _tmain(int argc, _TCHAR* argv[]) {vector<string> words;string temp;string disliked = "Broccoli";while(cin>>temp){if(temp == disliked){/*Beep 第一個參數 The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF). 第二個參數 The duration of the sound, in milliseconds.*/Beep(500,500); break;}words.push_back(temp);}cout<<"Number of words: "<<words.size()<<endl;sort(words.begin(),words.end());//#include <algorithm>for(int i = 0;i<words.size();i++){if(i==0||words[i-1]!=words[i]){cout<<words[i]<<endl;}}system("pause");return 0; }轉載于:https://www.cnblogs.com/Daywei/archive/2011/01/11/Notes2.html
總結
以上是生活随笔為你收集整理的学习C++之父的最新姐妹作笔记2的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么更改U盘码 “U盘码修改方法”
- 下一篇: PHP下使用FPDF在PDF中插入图片