91.生成ini文件并写入和读取ini文件
- 写入
WritePrivateProfileStringA("hello money", infx[i].name, money, "1.ini");
- 按照字符串读取
GetPrivateProfileStringA("hello money", infx[i].name, "NULL", money, , "1.ini");函数原型:
GetPrivateProfileStringA(
_In_opt_ LPCSTR lpAppName,
_In_opt_ LPCSTR lpKeyName,
_In_opt_ LPCSTR lpDefault,
_Out_writes_to_opt_(nSize, return +) LPSTR lpReturnedString,
_In_ DWORD nSize,
_In_opt_ LPCSTR lpFileName
);GetPrivateProfileIntA(
_In_ LPCSTR lpAppName,
_In_ LPCSTR lpKeyName,
_In_ INT nDefault,
_In_opt_ LPCSTR lpFileName
);按照int类型读取,结果在返回值
int num=;
num=GetPrivateProfileIntA("hello money", infx[i].name, num, "1.ini");//结果在返回值
完整代码
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include <Windows.h> //创建结构体写入ini
struct info
{
char name[];
int money; }; void main()
{
//初始化
struct info infx[] = { { "xiaowang", }, { "xiaoli", }, { "xiaosun", }, { "xiaozhou", }, { "xiaobin", } };
//写入ini文件
//for (int i = 0; i < 5;i++)
//{
// char money[40] = { 0 };
// //把int类型转换为char*类型
// _itoa(infx[i].money, money, 10);
// //不指定路径,会写入系统目录
// WritePrivateProfileStringA("hello money", infx[i].name, money, "F:\\智锋\\20150526\\ini文件\\ini文件\\1.ini");
//} for (int i = ; i < ;i++)
{
//根据姓名读取到字符串
//char money[40] = { 0 };
//GetPrivateProfileStringA("hello money", infx[i].name, "NULL", money, 40, "F:\\智锋\\20150526\\ini文件\\ini文件\\1.ini");
//printf("\n%s %s",infx[i].name, money);
/*GetPrivateProfileStringA(
_In_opt_ LPCSTR lpAppName,
_In_opt_ LPCSTR lpKeyName,
_In_opt_ LPCSTR lpDefault,
_Out_writes_to_opt_(nSize, return +1) LPSTR lpReturnedString,
_In_ DWORD nSize,
_In_opt_ LPCSTR lpFileName
);*/
/* GetPrivateProfileIntA(
_In_ LPCSTR lpAppName,
_In_ LPCSTR lpKeyName,
_In_ INT nDefault,
_In_opt_ LPCSTR lpFileName
);*/
//根据姓名读取到int类型中
int num=;
num = GetPrivateProfileIntA("hello money", infx[i].name, num, "1.ini");
printf("%d\n", num);
}
system("pause");
}
91.生成ini文件并写入和读取ini文件的更多相关文章
- INI文件的写入与读取
INI文件的写入与读取 [节名] '[]中的节名对应此API的第一参数 Name=内容 'Nmae对应此API的第二参数 API的第三参数是没有取到匹配内容时返回的字符串; ...
- 装饰者模式的学习(c#) EF SaveChanges() 报错(转载) C# 四舍五入 保留两位小数(转载) DataGridView样式生成器使用说明 MSSQL如何将查询结果拼接成字符串 快递查询 C# 通过smtp直接发送邮件 C# 带参访问接口,WebClient方式 C# 发送手机短信 文件 日志 写入 与读取
装饰者模式的学习(c#) 案例转自https://www.cnblogs.com/stonefeng/p/5679638.html //主体基类 using System;using System.C ...
- C# winform写入和读取TXT文件
C# winform写入和读取TXT文件 string str; str=this.textBox1.Text; StreamWriter sw = new ...
- winform 写入和读取TXT文件
C# winform写入和读取TXT文件 string str; str=this.textBox1.Text; StreamWriter sw = new StreamWriter(Applicat ...
- 在C#程序中,创建、写入、读取XML文件的方法
一.在C#程序中,创建.写入.读取XML文件的方法 1.创建和读取XML文件的方法,Values为需要写入的值 private void WriteXML(string Values) { //保存的 ...
- [转]VC++中对文件的写入和读取
本文转自:http://blog.csdn.net/fanghb_1984/article/details/7425705 本文介绍两种方法对文件进行读取和写入操作:1.采用fstream类:2.采用 ...
- java的bio和nio写入及读取txt文件
一.bio的写入及读取 1.采用bio之BufferedWriter 写入文件 public static void main(String[] args) throws IOException { ...
- android文件的写入与读取---简单的文本读写context.openFileInput() context.openFileOutput()
最终效果图,点击save会保存到文件中,点击show会从文件中读取出内容并显示. main.xml <?xml version="1.0" encoding=" ...
- 第十七章,txt文件的写入和读取数据结合练习(C++)
#include <iostream> #include <fstream> int main(int argc, char** argv) { std::string str ...
随机推荐
- IDEA设置注释模板最佳实践
效果 在方法上输入/**,然后按tab键,生成的效果如下 配置步骤 1. 在Live Templates中添加模板组,命名随意,主要是为了存放自定义的模板,方便管理 2. 在模板组下添加一个模板,具体 ...
- 使用PyV8模块破解网站加密cookie
PyV8是Chromium中内嵌的javascript引擎,号称跑的最快.PyV8是用Python在V8的外部API包装了一个python壳,这样便可以使python可以直接与javascript操作 ...
- 今日SGU 5.17
SGU 119 题意:给你一个0-15组成的4*4的矩形,问你能不能回到正常 收获:把矩形变成一维数组,然后判断当前矩形状态到目标状态(逆序对为15)逆序对和0到目标的奇偶性是否不相同,证明题,引荐大 ...
- Asp.Net Core 之 appsettings.json
原文:Asp.Net Core 之 appsettings.json appsettings.json是什么? 相信大家在.Net Framework的项目都会用的web.config,app.con ...
- flex RemoteObject 的两种使用方法
这里使用的是django1.6 和 postgreSQL9.0 FlashBuilder4.5 django方面就不说了,根据文档来做,建好模块,配置好数据库等等 创建 gateway 和 time ...
- 菜鸟之路——Java并发(二)ThreadLocal
一.什么是ThreadLocal ThreadLocal,非常多地方叫做线程本地变量,也有些地方叫做线程本地存储.事实上意思几乎相同.非常多博客都这样说:ThreadLocal为解决多线程程序 ...
- java中TCP传输协议
class TcpClient { public static void main(String[] args) throws Exception { //创建client的socket服务,指定目的 ...
- hdoj-1593-find a way to escape【数学题】
find a way to escape Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- sdut 2805(最小生成树)
大家快来A水题 Time Limit: 1000MS Memory limit: 65536K 题目描写叙述 (1<= N <=2000)(1<= M <= N*(N-1)/2 ...
- 九度 题目1154:Jungle Roads
题目描写叙述: The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid mon ...