|
|||
<script type=text/javascript> function showFrameMenu(p_el) { if ((typeof(Spaces) != "undefined") && Spaces.PartFrame) { Spaces.PartFrame.showMenu(p_el, 'http/x3a/x2f/x2fspaces.live.com/x2fapi.aspx/x3fwx_action/x3daddModule/x26mkt/x3dzh-CN/x26wx_targetSite/x3dPersonalSpaces/x26wxp_url/x3d/x7b0/x7d'); } return false; } var g_siteType = "PersonalSpace"; </script>
|
1, 指向常量的指针&&指针常量 Char ch[5]=”lisi”; 2, 读写 文件读取操作 char ch[100]="0"; //数组被赋值为全零 //char ch[100]; //如果不把数组赋零,也可以在写入文件中多写一个空字符 3, 获取文件大小 fseek(pFile,0,SEEK_END); //把文件指针移到文件末尾 rewind(pFile); //把指针移回文件头 fseek(pFile,0,SEEK_BEGIN) 4, 文本和二进制方式。读取和写入的保持一致 二进制:将数据在内存中的存储形式原样输出到文件中 5, 字符和数字 FILE *pFile=fopen("2.txt","w"); int i=98341; //非要使他可用,可增加itoa(i,ch,10); 6, C++中文件操作 需要加头文件#include "fstream.h" 读文件: ifstream ifs("3.txt",ios::in); //循环读取文件每一行 While(!ifs.getline(ch,100).eof()) {//do something with data in buffer ch } 下一次重新getline之前,需要 ifs.clear()清除eof标志 7, Win32API函数存取文件 (1)写入 8, SDK方法 (1)写入: CFile file("7.txt",CFile::modeCreate | CFile::modeWrite); (2)读取: CFile file("7.txt",CFile::modeRead); pBuf=new char[i+1]; pBuf[i]=0; file.Close(); 9, 构造文件对话框,存取文件方法 (1)写入: CFileDialog fileDlg(FALSE); (2)读取 CFileDialog fileDlg(TRUE); } 10, 读写配置文件 CXXXApp::InitInstance(){ // 写在SetRegistryKey(_T("Local AppWizard-Generated Applications"));之后(也可以重新设置表项) ::WriteProfileString("songpeng","sp","song");用来在C:/WINDOWS/win.ini中写入数据。一方面为了兼容十六位程序,另一方面提高程序运行速度 CString str; } 11, 读写注册表 读写配置文件的函数WriteProfileString(),GetProfileString()在win32下自动成为注册表的读写。 SetRegistryKey(_T("Local AppWizard-Generated Applications"));用来在注册表的HKEY_CURRENT_USER->Software下增加主键Local AppWizard-Generated Applications (1)写入注册表: HKEY hkey; RegCloseKey(hkey); (2)读取注册表 注意要先获取字段大小 LONG lValue; LONG RegQueryValue( HKEY hkey; 其他函数: RegDeleteKey(); RegDeleteValue();等 第12课 文件操作 1.常量指针与指针常量的区分 |
学习笔记
最新推荐文章于 2024-04-24 19:52:50 发布
<script type=text/javascript> function search() { // If the page is dirty and we prompt the user to ok/cancel the navigation, and they // select cancel, window.location.href assignment will throw. In this case, we want to // simply ignore it. try { window.location.href = "http://home.services.spaces.live.com/search/?tp=1&pg=0&sc=0&form=SPDEPS" + "&q=" + encodeURIComponent(document.getElementById("uxp_hdr_searchInput").value); } catch (e) {} } </script>
<script type=text/javascript>function uxp_p(t){t.parentNode.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+t.src+"')";}</script>
<script src="http://shared.live.com/w0cBUAeJzxpl2BKWb!s3qg/header.js" defer type=text/javascript></script>