青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 45,  comments - 232,  trackbacks - 0

昨天寫了個一組ini文件讀寫函數(shù)。提供大家使用,已經(jīng)在XP+VC7.1和FC6+GCC4.1,ARM9+arm-linux-gcc3.3中測試過了,可以跨平臺使用。使用標(biāo)準(zhǔn)C寫得,支持C++。源程序可以到:http://m.shnenglu.com/Files/dyj057/inifile.zip下載。

 

/* *
*@file             inifile.h
*@cpright        (C)2007 GEC 
*@auther        dengyangjun
*@email        dyj057@gmail.com
*@version        0.1
*@create         2007-1-14 
*@modify        2007-1-14
*@brief            declare ini file operation
*@note
*@history    
*/

#ifndef INI_FILE_H_
#define  INI_FILE_H_

#ifdef __cplusplus
extern   " C "
{
#endif

int  read_profile_string(  const   char   * section,  const   char   * key, char   * value,  int  size,  const   char   * file);
int  read_profile_int(  const   char   * section,  const   char   * key, int  default_value,  const   char   * file);

int  write_profile_string(  const   char   * section,  const   char   * key, const   char   * value,  const   char   * file);

#ifdef __cplusplus
}; 
// end of extern "C" {
#endif

#endif   // end of INI_FILE_H_

 

/* *
*@file             inifile.c
*@cpright        (C)2007 GEC
*@auther        dengyangjun
*@email        dyj057@gmail.com
*@version        0.1
*@create         2007-1-14 
*@modify        2007-1-14
*@brief            implement ini file operation
*@note
*@history    
*/
#include 
< stdio.h >
#include 
< stdlib.h >
#include 
< assert.h >
#include 
< string .h >
#include 
< ctype.h >

#include 
" inifile.h "

#ifdef __cplusplus
extern   " C "
{
#endif

#define  MAX_FILE_SIZE 8096

#define  LEFT_BRACE '['
#define  RIGHT_BRACE ']'

static   int  load_ini_file( const   char   * file,  char   * buf, int   * file_size)
{
    FILE 
* in   =  NULL;
    
int  i = 0 ;
    
* file_size  = 0 ;

    assert(file 
!= NULL);
    assert(buf 
!= NULL);

    
in   =  fopen(file, " r " );
    
if ( NULL  ==   in ) {
        
return   0 ;
    }

    
// load initialization file
     while ((buf[i] = fgetc( in )) != EOF) {
        i
++ ;
        assert( i 
<  MAX_FILE_SIZE);  // file too big
    }
    
    buf[i]
= ' \0 ' ;
    
* file_size  =  i;

    fclose(
in );
    
return   1 ;
}

/*
*<summary></summary>
* <returns>Result of the addtion(int)</returns>
* <param name="x"></param>
* <param name="y"></param>
*/

static   int  isnewline( char  c)
{
    
return  ( ' \n '   ==  c  ||    ' \r '   ==  c ) ?   1  :  0 ;
}
static   int  isend( char  c)
{
    
return   ' \0 ' == c ?   1  :  0 ;
}
static   int  isleftbarce( char  c)
{
    
return  LEFT_BRACE  ==  c ?   1  :  0 ;
}
static   int  isrightbrace( char  c )
{
    
return  RIGHT_BRACE  ==  c ?   1  :  0 ;
}
static   int  parse_file( const   char   * section,  const   char   * key,  const   char   * buf, int   * sec_s, int   * sec_e,
                      
int   * key_s, int   * key_e,  int   * value_s,  int   * value_e)
{
    
const   char   * =  buf;
    
int  i = 0 ;

    assert(buf
!= NULL);
    assert(section 
!=  NULL  &&  strlen(section));
    assert(key 
!=  NULL  &&  strlen(key));

    
* sec_e  =   * sec_s  =   * key_e  =   * key_s  =   * value_s  =   * value_e  =   - 1 ;

    
while ! isend(p[i]) )
    {
        
// find the section
         if ( (  0 == ||   isnewline(p[i - 1 ]) )  &&  isleftbarce(p[i]) )
        {
            
int  section_start = i + 1 ;

            
// find the ']'
             do
            {
                i
++ ;
            }
while ! isrightbrace(p[i])  &&   ! isend(p[i]));

            
if 0   ==  strncmp(p + section_start,section, i - section_start))
            {
                
int  newline_start = 0 ;

                i
++ ;

                
// Skip over space char after ']'
                 while (isspace(p[i]))
                {
                    i
++ ;
                }

                
// find the section
                 * sec_s  =  section_start;
                
* sec_e  =  i;

                
while !  (isnewline(p[i - 1 ])  &&  isleftbarce(p[i]))  &&   ! isend(p[i]) )
                {
                    
int  j = 0 ;
                    
// get a new line
                    newline_start  =  i;

                    
while ! isnewline(p[i])  &&    ! isend(p[i]) )
                    {
                        i
++ ;
                    }
                    
// now i  is equal to end of the line

                    j
= newline_start;

                    
if ( ' ; '   !=  p[j])  // skip over comment
                    {
                        
while (j  <  i  &&  p[j] != ' = ' )
                        {
                            j
++ ;
                            
if ( ' = '   ==  p[j])
                            {
                                
if (strncmp(key,p + newline_start,j - newline_start) == 0 )
                                {
                                    
// find the key ok
                                     * key_s  =  newline_start;
                                    
* key_e  =  j - 1 ;

                                    
* value_s  =  j + 1 ;
                                    
* value_e  =  i;

                                    
return   1 ;
                                }
                            }
                        }
                    }

                    i
++ ;
                }
            }
        }
        
else
        {
            i
++ ;
        }
    }
    
return   0 ;
}

/* *
* @brief read_profile_string <d>retrieves a string from the specified section in an initialization file.
* @param section  <t>const char * <in> <d>name of the section containing the key name.
* @param key  <t>const char *  <in><d>the name of the key whose associated string is to be retrieved.
* @param value <t>char * <out><d>pointer to the buffer that receives the retrieved string.      
* @return <t>int  <n>1 : read success; 0 : read fail.
*/       
int  read_profile_string(  const   char   * section,  const   char   * key, char   * value,   int  size,  const   char   * file)
{
    
char  buf[MAX_FILE_SIZE] = { 0 };
    
int  file_size;
    
int  sec_s,sec_e,key_s,key_e, value_s, value_e;

    
// check parameters
    assert(section  !=  NULL  &&  strlen(section));
    assert(key 
!=  NULL  &&  strlen(key));
    assert(value 
!=  NULL);
    assert(size 
>   0 );
    assert(file 
!= NULL  && strlen(key));

    
if ! load_ini_file(file,buf, & file_size))
        
return   0 ;

    
if ( ! parse_file(section,key,buf, & sec_s, & sec_e, & key_s, & key_e, & value_s, & value_e))
    {
        
return   0 // not find the key
    }
    
else
    {
        
int  cpcount  =  value_e  - value_s;

        
if ( size - 1   <  cpcount)
        {
            cpcount 
=   size - 1 ;
        }
    
        memset(value, 
0 , size);
        memcpy(value,buf
+ value_s, cpcount );
        value[cpcount] 
=   ' \0 ' ;

        
return   1 ;
    }
}


int  read_profile_int(  const   char   * section,  const   char   * key, int  default_value,  const   char   * file)
{
    
char  value[ 32 =  { 0 };
    
if ( ! read_profile_string(section,key,value,  sizeof (value),file))
    {
        
return  default_value;
    }
    
else
    {
        
return  atoi(value);
    }
}

int  write_profile_string(  const   char   * section,  const   char   * key, const   char   * value,  const   char   * file)
{
    
char  buf[MAX_FILE_SIZE] = { 0 };
    
char  w_buf[MAX_FILE_SIZE] = { 0 };
    
int  sec_s,sec_e,key_s,key_e, value_s, value_e;
    
int  value_len  =  ( int )strlen(value);
    
int  file_size;
    FILE 
* out ;

    
// check parameters
    assert(section  !=  NULL  &&  strlen(section));
    assert(key 
!=  NULL  &&  strlen(key));
    assert(value 
!=  NULL);
    assert(file 
!= NULL  && strlen(key));

    
if (!load_ini_file(file,buf, & file_size))
    {
        sec_s 
=   - 1 ;
    }
    
else
    {
        parse_file(section,key,buf,
& sec_s, & sec_e, & key_s, & key_e, & value_s, & value_e);
    }

    
if - 1   ==  sec_s)
    {
        
        
if ( 0 == file_size)
        {
            sprintf(w_buf
+ file_size, " [%s]\n%s=%s\n " ,section,key,value);
        }
        
else
        {
            
// not find the section, then add the new section at end of the file
            memcpy(w_buf,buf,file_size);
            sprintf(w_buf
+ file_size, " \n[%s]\n%s=%s\n " ,section,key,value);
        }
        
        
    }
    
else   if ( - 1   ==  key_s)
    {
        
// not find the key, then add the new key & value at end of the section
        memcpy(w_buf,buf,sec_e);
        sprintf(w_buf
+ sec_e, " %s=%s\n " ,key,value);
        sprintf(w_buf
+ sec_e + strlen(key) + strlen(value) + 2 ,buf + sec_e, file_size  -  sec_e);
    }
    
else
    {
        
// update value with new value
        memcpy(w_buf,buf,value_s);
        memcpy(w_buf
+ value_s,value, value_len);
        memcpy(w_buf
+ value_s + value_len, buf + value_e, file_size  -  value_e);
    }
    
    
out   =  fopen(file, " w " );
    
if (NULL  ==   out )
    {
        
return   0 ;
    }
    
    
if ( - 1   ==  fputs(w_buf, out ) )
    {
        fclose(
out );
        
return   0 ;
    }

    fclose(
out );
    
    
return   1 ;
}


#ifdef __cplusplus
}; 
// end of extern "C" {
#endif

 

 

#include  < stdio.h >
#include 
" inifile.h "

// main.c
#define  BUF_SIZE 256
int  main()
{
    
const   char   * file  = " myconfig.ini " ;
    
const   char   * section  =   " Db " ;
    
const   char   * key  =   " XX2 " ;
    
    
char  value[BUF_SIZE] = { 0 };
    
    printf(
" test get profile string\n " );

    
if ( ! read_profile_string(section, key, value, BUF_SIZE,"", file))
    {
        
        printf(
" read ini file fail\n " );
    }
    
else
    {
        
int  x  =  read_profile_int(section,key, 0 ,file);
        printf(
" XX2=%d\n " , x);
        printf(
" read: [%s] = [%s]\n " ,key,value);
    }
    
    
if ( ! write_profile_string(section, " XX2 " , " 2writeOK " ,file))
    {
        printf(
" write ini file fail\n " );
    }
    
else
    {
        printf(
" write ini file ok\n " );
    }
    
    
return   0 ;
}


posted on 2006-01-24 16:37 天下無雙 閱讀(13841) 評論(32)  編輯 收藏 引用 所屬分類: C/C++

FeedBack:
# re: Ini文件讀寫類(ISO-C++)
2006-04-22 12:52 | S
SDFSDF  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API
2007-03-08 16:43 | leafy
函數(shù)不錯,只是有個小bug:
在int write_profile_string里,需要把

if (load_ini_file(file,buf, & file_size))
{
sec_s = - 1 ;
}
else
{
parse_file(section,key,buf, & sec_s, & sec_e, & key_s, & key_e, & value_s, & value_e);
}

改成
if ( ! load_ini_file(file,buf, & file_size))
return 0 ;

if ( ! parse_file(section,key,buf, & sec_s, & sec_e, & key_s, & key_e, & value_s, & value_e))
{
return 0 ; // not find the key
}

  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API
2007-03-08 16:47 | leafy
樓主的意思應(yīng)該是這樣(讀取不成功,則創(chuàng)建):(少了個非)
if (!load_ini_file(file,buf, & file_size))
{
sec_s = - 1 ;
}
else
{
parse_file(section,key,buf, & sec_s, & sec_e, & key_s, & key_e, & value_s, & value_e);
}
  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API
2007-03-08 16:49 | 天下無雙
不好意思,我在自己的新版本的代碼中改了,網(wǎng)上的版本還沒有更新。謝謝指正。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API
2007-03-08 16:54 | 天下無雙
對,就是少寫了那個!符號。我是這樣改的。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API
2007-04-06 16:47 | kate
寫的不錯
提個問題:
在parse_file中有沒有考慮注釋行, 比如";this is a comement"
  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API
2007-04-07 09:02 | 天下無雙
if ( ' ; ' != p[j]) // skip over comment
代碼中這句話就是跳過注釋的。有這個功能。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-06-26 11:25 | cxczqfrx

#include < stdio.h >
#include " inifile.h "

// main.c
#define BUF_SIZE 256
int main()
{
const char * file = " myconfig.ini " ;
const char * section = " Db " ;
const char * key = " XX2 " ;

char value[BUF_SIZE] = { 0 };

printf( " test get profile string\n " );

if ( ! read_profile_string(section, key, value, BUF_SIZE, file))
{

printf( " read ini file fail\n " );
}
else
{
int x = read_profile_int(section,key, 0 ,file);
printf( " XX2=%d\n " , x);
printf( " read: [%s] = [%s]\n " ,key,value);
}

if ( ! write_profile_string(section, " XX2 " , " 2writeOK " ,file))
{
printf( " write ini file fail\n " );
}
else
{
printf( " write ini file ok\n " );
}

return 0 ;
}

測試了下,編譯提示read_profile_string 缺少參數(shù),改為
if ( ! read_profile_string(section, key, value, BUF_SIZE,NULL, file))
后,能寫入文件,但讀取失敗。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-06-26 17:04 | 天下無雙
讀取失敗,怎么會呢?看看你的代碼。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-06-26 20:23 | cxczqfrx
#include <stdio.h>
#include "inifile.c"

// main.c
#define BUF_SIZE 256
int main()
{
const char * file = " myconfig.ini " ;
const char * section = " Db " ;
const char * key = " XX2 " ;

char value[BUF_SIZE] = { 0 };

printf( " test get profile string\n " );

if ( ! read_profile_string(section, key, value, BUF_SIZE,NULL, file))
{

printf( " read ini file fail\n " );
}
else
{
int x = read_profile_int(section,key, 0 ,file);
printf( " XX2=%d\n " , x);
printf( " read: [%s] = [%s]\n " ,key,value);
}

if ( ! write_profile_string(section, " XX2 " , " 2writeOK " ,file))
{
printf( " write ini file fail\n " );
}
else
{
printf( " write ini file ok\n " );
}

return 0 ;
}



/**
* @file
* @brief initialization file read and write API
* @author Deng Yangjun
* @date 2007-1-9
* @version 0.1
*/

#ifndef INI_FILE_H_
#define INI_FILE_H_

#ifdef __cplusplus
extern "C"
{
#endif

int read_profile_string( const char *section, const char *key,char *value, int size,const char *default_value, const char *file);
int read_profile_int( const char *section, const char *key,int default_value, const char *file);
int write_profile_string( const char *section, const char *key,const char *value, const char *file);

#ifdef __cplusplus
}; //end of extern "C" {
#endif

#endif //end of INI_FILE_H_

  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-06-26 20:28 | cxczqfrx
/**
* @file
* @brief initialization file read and write API implementation
* @author Deng Yangjun
* @date 2007-1-9
* @version 0.1
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>

#include "inifile.h"

#ifdef __cplusplus
extern "C"
{
#endif

#define MAX_FILE_SIZE 1024*16
#define LEFT_BRACE '['
#define RIGHT_BRACE ']'

static int load_ini_file(const char *file, char *buf,int *file_size)
{
FILE *in = NULL;
int i=0;
*file_size =0;

assert(file !=NULL);
assert(buf !=NULL);

in = fopen(file,"r");
if( NULL == in) {
return 0;
}

buf[i]=fgetc(in);

//load initialization file
while( buf[i]!= (char)EOF) {
i++;
assert( i < MAX_FILE_SIZE); //file too big
buf[i]=fgetc(in);
}

buf[i]='\0';
*file_size = i;

fclose(in);
return 1;
}

static int isnewline(char c)
{
return ('\n' == c || '\r' == c )? 1 : 0;
}
static int isend(char c)
{
return '\0'==c? 1 : 0;
}
static int isleftbarce(char c)
{
return LEFT_BRACE == c? 1 : 0;
}
static int isrightbrace(char c )
{
return RIGHT_BRACE == c? 1 : 0;
}
static int parse_file(const char *section, const char *key, const char *buf,int *sec_s,int *sec_e,
int *key_s,int *key_e, int *value_s, int *value_e)
{
const char *p = buf;
int i=0;

assert(buf!=NULL);
assert(section != NULL && strlen(section));
assert(key != NULL && strlen(key));

*sec_e = *sec_s = *key_e = *key_s = *value_s = *value_e = -1;

while( !isend(p[i]) ) {
//find the section
if( ( 0==i || isnewline(p[i-1]) ) && isleftbarce(p[i]) )
{
int section_start=i+1;

//find the ']'
do {
i++;
} while( !isrightbrace(p[i]) && !isend(p[i]));

if( 0 == strncmp(p+section_start,section, i-section_start)) {
int newline_start=0;

i++;

//Skip over space char after ']'
while(isspace(p[i])) {
i++;
}

//find the section
*sec_s = section_start;
*sec_e = i;

while( ! (isnewline(p[i-1]) && isleftbarce(p[i]))
&& !isend(p[i]) ) {
int j=0;
//get a new line
newline_start = i;

while( !isnewline(p[i]) && !isend(p[i]) ) {
i++;
}

//now i is equal to end of the line
j = newline_start;

if(';' != p[j]) //skip over comment
{
while(j < i && p[j]!='=') {
j++;
if('=' == p[j]) {
if(strncmp(key,p+newline_start,j-newline_start)==0)
{
//find the key ok
*key_s = newline_start;
*key_e = j-1;

*value_s = j+1;
*value_e = i;

return 1;
}
}
}
}

i++;
}
}
}
else
{
i++;
}
}
return 0;
}
  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-06-26 20:29 | cxczqfrx

/**
*@brief read string in initialization file\n
* retrieves a string from the specified section in an initialization file
*@param section [in] name of the section containing the key name
*@param key [in] name of the key pairs to value
*@param value [in] pointer to the buffer that receives the retrieved string
*@param size [in] size of value buffer
*@param default_value [in] defualt value of result
*@param file [in] path of the initialization file
*@return 1 : read success; \n 0 : read fail
*/
int read_profile_string( const char *section, const char *key,char *value,
int size, const char *default_value, const char *file)
{
char buf[MAX_FILE_SIZE]={0};
int file_size;
int sec_s,sec_e,key_s,key_e, value_s, value_e;

//check parameters
assert(section != NULL && strlen(section));
assert(key != NULL && strlen(key));
assert(value != NULL);
assert(size > 0);
assert(file !=NULL &&strlen(key));

if(!load_ini_file(file,buf,&file_size))
{
if(default_value!=NULL)
{
strncpy(value,default_value, size);
}
return 0;
}

if(!parse_file(section,key,buf,&sec_s,&sec_e,&key_s,&key_e,&value_s,&value_e))
{
if(default_value!=NULL)
{
strncpy(value,default_value, size);
}
return 0; //not find the key
}
else
{
int cpcount = value_e -value_s;

if( size-1 < cpcount)
{
cpcount = size-1;
}

memset(value, 0, size);
memcpy(value,buf+value_s, cpcount );
value[cpcount] = '\0';

return 1;
}
}

/**
*@brief int value in initialization file\n
* retrieves int value from the specified section in an initialization file
*@param section [in] name of the section containing the key name
*@param key [in] name of the key pairs to value
*@param default_value [in] defualt value of result
*@param file [in] path of the initialization file
*@return profile int value,if read fail, return default value
*/
int read_profile_int( const char *section, const char *key,int default_value,
const char *file)
{
char value[32] = {0};
if(!read_profile_string(section,key,value, sizeof(value),NULL,file))
{
return default_value;
}
else
{
return atoi(value);
}
}

/**
* @brief write a profile string to a ini file
* @param section [in] name of the section,can't be NULL and empty string
* @param key [in] name of the key pairs to value, can't be NULL and empty string
* @param value [in] profile string value
* @param file [in] path of ini file
* @return 1 : success\n 0 : failure
*/
int write_profile_string(const char *section, const char *key,
const char *value, const char *file)
{
char buf[MAX_FILE_SIZE]={0};
char w_buf[MAX_FILE_SIZE]={0};
int sec_s,sec_e,key_s,key_e, value_s, value_e;
int value_len = (int)strlen(value);
int file_size;
FILE *out;

//check parameters
assert(section != NULL && strlen(section));
assert(key != NULL && strlen(key));
assert(value != NULL);
assert(file !=NULL &&strlen(key));

if(!load_ini_file(file,buf,&file_size))
{
sec_s = -1;
}
else
{
parse_file(section,key,buf,&sec_s,&sec_e,&key_s,&key_e,&value_s,&value_e);
}

if( -1 == sec_s)
{

if(0==file_size)
{
sprintf(w_buf+file_size,"[%s]\n%s=%s\n",section,key,value);
}
else
{
//not find the section, then add the new section at end of the file
memcpy(w_buf,buf,file_size);
sprintf(w_buf+file_size,"\n[%s]\n%s=%s\n",section,key,value);
}
}
else if(-1 == key_s)
{
//not find the key, then add the new key & value at end of the section
memcpy(w_buf,buf,sec_e);
sprintf(w_buf+sec_e,"%s=%s\n",key,value);
sprintf(w_buf+sec_e+strlen(key)+strlen(value)+2,buf+sec_e, file_size - sec_e);
}
else
{
//update value with new value
memcpy(w_buf,buf,value_s);
memcpy(w_buf+value_s,value, value_len);
memcpy(w_buf+value_s+value_len, buf+value_e, file_size - value_e);
}

out = fopen(file,"w");
if(NULL == out)
{
return 0;
}

if(-1 == fputs(w_buf,out) )
{
fclose(out);
return 0;
}

fclose(out);
return 1;
}


#ifdef __cplusplus
}; //end of extern "C" {
#endif


最后的結(jié)果文件 myconfig.ini內(nèi)容:

[ Db ]
XX2 = 2writeOK
XX2 = 2writeOK
XX2 = 2writeOK
XX2 = 2writeOK
XX2 = 2writeOK


看起來好像是運(yùn)行幾次,就寫幾次新內(nèi)容,但原來的內(nèi)容不能讀取
使用devcpp編譯  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-06-27 10:05 | 天下無雙
請從下載鏈接處下載文件,然后更新原來的工程。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-07-12 16:03 | 拼命蘿卜
請問支持value=后面的值是多行嗎?  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-07-14 09:03 | 天下無雙
只能是一行。而且在‘=’后面不能有空格。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-11-08 20:12 | team2vx
大家的調(diào)試都沒有問題嗎?

我的提示
\main.c(16) : error C2198: 'read_profile_string' : too few actual parameters
inifile.cpp
Error executing cl.exe.

main.exe - 1 error(s), 0 warning(s)

是怎么一回事啊?  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-11-08 21:45 | team2vx
同樣的問題, 讀取失敗但是可以 寫進(jìn)去,不知道其他 人都運(yùn)行成功了嗎?  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-11-08 21:49 | 天下無雙
測試通過了,沒有問題.請放心使用.  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-11-09 07:53 | vxking
不知道 無雙現(xiàn)在還在不?
可是我的的確是不能通過,我把代碼上傳了你能幫我看下嗎

http://m.shnenglu.com/Files/vxking/inifile.rar

急用,謝謝  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)[未登錄]
2007-11-11 16:32 | 天下無雙
你的文件調(diào)用read_profile_string時候少了一個參數(shù)。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-11-14 17:32 | vxking
你好
現(xiàn)在得問題不是 參數(shù)
能通過運(yùn)行
但是一直讀取失敗
read ini file fail  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-12-06 11:21 | yuan xiaowei
多謝,已經(jīng)移植到我的板子上了;不過用的是yaffs2文件系統(tǒng)

yuanxiaoweisz@hotmail.com  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API (已更新)
2007-12-07 09:10 | 天下無雙
如果要寫入的話,肯定是是要把它ini文件放在可寫分區(qū)的。所以放在yaffs文件系統(tǒng)中沒有問題。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API v0.1.0 (已更新)
2007-12-10 09:26 | 天下無雙
已經(jīng)有新版本發(fā)布。請大家使用新版本:http://m.shnenglu.com/dyj057/archive/2007/12/09/38074.html  回復(fù)  更多評論
  
# 函數(shù)庫有這個功能嗎?
2008-05-09 13:03 | wuxunfeng
謝謝樓主的共享。
有個問題想問一下。如果 INI文件中,同一個SECTION中,有幾個同樣的KEY,那么讀取的時候,會讀取哪個KEY呢,可以循環(huán)讀取嗎.例:
[SECTION]
key=data
key=data
key=data
key1=data2  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API v0.1.0 (已更新)
2008-11-17 16:14 | 小菜
讀 寫 的 函數(shù)怎么調(diào)用啊 試了幾次 沒弄明白。。。。。。。。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API v0.1.0 (已更新)
2008-11-18 16:07 | 樓主
不能循環(huán)讀寫。
@小菜,先引入源文件到工程中,然后在需要的地方引入頭文件,再使用函數(shù)。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API v0.1.0 (已更新)
2009-01-24 13:01 | 測試測試
性能太差,  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API v0.1.0 (已更新)
2009-07-20 15:52 |
經(jīng)過測試,不能跳過注釋  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API v0.1.0 (已更新)
2009-11-01 22:28 | kongwch
樓主真是大好人啊,我已經(jīng)測試通過,不過parse_file函數(shù)里面有個bug,如果字段不存在的話會導(dǎo)致內(nèi)存越界,應(yīng)該修改為:
}
}
}
}
if (! isend(p[i]) )
{
i ++ ;
}
}
}
}
  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API v0.1.0 (已更新)
2010-08-02 19:46 | zhetengfengzi
@路過
可以參考下 http://blog.csdn.net/ddddfw888/archive/2010/08/02/5783165.aspx, 我已經(jīng)對這個做了相關(guān)的修改。  回復(fù)  更多評論
  
# re: C/C++跨平臺ini文件讀寫API v0.1.0 (已更新)
2010-10-26 21:20 | 股票計算器
謝謝  回復(fù)  更多評論
  

常用鏈接

留言簿(15)

隨筆分類

隨筆檔案

相冊

我的其它領(lǐng)域Blog

搜索

  •  

積分與排名

  • 積分 - 207929
  • 排名 - 129

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲图片欧美一区| 国产精品亚发布| 欧美一级淫片播放口| 欧美在线观看一二区| 免费在线成人| 国产亚洲精品7777| 国内成人在线| 亚洲综合色激情五月| 亚洲精品久久久久久一区二区| 亚洲欧美影音先锋| 国产精品乱码一区二区三区| 一区二区三区日韩欧美精品| 亚洲免费av观看| 欧美精品国产精品日韩精品| 亚洲欧洲一区二区在线观看| 欧美激情一区二区三区在线视频| 久久香蕉国产线看观看网| 樱花yy私人影院亚洲| 久久久人成影片一区二区三区观看 | 亚洲国产精品久久人人爱蜜臀 | 午夜在线播放视频欧美| 亚洲日本免费| 免费亚洲视频| 日韩亚洲视频在线| 亚洲美女福利视频网站| 欧美理论大片| 夜夜精品视频一区二区| 一区二区精品| 国产亚洲精品综合一区91| 久久免费偷拍视频| 久久久久久9999| 亚洲高清在线观看| 亚洲国产精品电影| 欧美午夜久久| 久久久91精品国产一区二区三区 | 日韩手机在线导航| 欧美色另类天堂2015| 欧美影片第一页| 久久蜜桃精品| 在线视频欧美一区| 午夜在线播放视频欧美| 在线成人黄色| 日韩亚洲在线观看| 国产亚洲精品久久久| 欧美高清视频一二三区| 欧美性久久久| 免费亚洲电影在线观看| 欧美日韩综合一区| 老司机精品视频一区二区三区| 久久久夜精品| 亚洲欧美日韩直播| 免费在线一区二区| 欧美中文字幕第一页| 久久在线精品| 亚洲欧美三级伦理| 美女视频网站黄色亚洲| 亚洲男人的天堂在线aⅴ视频| 久久国产福利国产秒拍| 亚洲一区二区三区国产| 久久这里只有| 久久精品女人| 欧美日韩一区二区三区四区五区| 久久露脸国产精品| 国产精品国产精品| 亚洲国产精品久久久| 国产一区自拍视频| 一区二区成人精品| 亚洲精品在线电影| 久久久av毛片精品| 先锋影音国产一区| 欧美日韩国产不卡| 女人天堂亚洲aⅴ在线观看| 国产欧美精品久久| 一区二区三区欧美在线| 亚洲国产一区二区精品专区| 亚洲一区二区成人| 亚洲视频在线免费观看| 久久综合网色—综合色88| 欧美亚一区二区| 欧美成人在线免费视频| 国内精品模特av私拍在线观看| 在线一区二区三区四区| 日韩一级精品| 欧美高清在线精品一区| 欧美搞黄网站| 亚洲国产精品视频| 久久亚洲国产精品日日av夜夜| 欧美在线一区二区| 国产伦精品一区二区三区视频黑人| 最新高清无码专区| 91久久精品国产91性色tv| 久久精品一区二区三区四区| 久久黄色网页| 国产中文一区二区| 久久久久久**毛片大全| 欧美 日韩 国产 一区| 尤物yw午夜国产精品视频| 久久精品在线| 免费日韩一区二区| 亚洲国产一区二区三区青草影视| 久久久久久亚洲精品中文字幕| 久久手机精品视频| 精品88久久久久88久久久| 久久福利毛片| 欧美激情一区三区| 9i看片成人免费高清| 欧美日韩在线不卡一区| 夜夜嗨av色一区二区不卡| 亚洲综合导航| 国产一区日韩二区欧美三区| 欧美一区二区三区男人的天堂 | 久久午夜激情| 亚洲国产乱码最新视频| 欧美成人自拍视频| 夜夜夜久久久| 欧美在线免费看| 在线观看三级视频欧美| 欧美a一区二区| 99精品免费| 久久九九精品99国产精品| 在线成人国产| 欧美午夜精品一区二区三区| 亚洲午夜国产一区99re久久| 欧美中在线观看| 亚洲肉体裸体xxxx137| 国产精品国产精品| 久久久99国产精品免费| 99成人在线| 久久精品亚洲一区二区| 亚洲福利电影| 欧美午夜三级| 久久伊人亚洲| av成人免费在线| 久久久免费观看视频| 亚洲日本久久| 国产一区再线| 欧美午夜寂寞影院| 久久久777| 欧美高清视频一二三区| 亚洲永久免费观看| 黄色精品免费| 国产精品成人v| 麻豆精品在线播放| 亚洲欧美日韩在线高清直播| 欧美黄色影院| 久久精品国产免费观看| 99国产精品久久久久久久久久| 国产老肥熟一区二区三区| 亚洲精品一二三| 久久免费视频一区| 一本久久综合亚洲鲁鲁五月天| 国产一区二区视频在线观看 | 一本到高清视频免费精品| 国产曰批免费观看久久久| 欧美日韩国产在线| 免费亚洲视频| 另类亚洲自拍| 欧美在线日韩| 亚洲图色在线| 99re在线精品| 欧美激情2020午夜免费观看| 久久精视频免费在线久久完整在线看 | 亚洲三级性片| 伊人久久综合| 激情综合在线| 国产综合久久久久久鬼色| 国产精品永久免费视频| 欧美亚洲第一页| 欧美日韩三级视频| 欧美日韩国产精品专区| 你懂的国产精品永久在线| 久久国产毛片| 久久男人av资源网站| 久久视频在线看| 老司机午夜精品| 免费人成精品欧美精品| 麻豆精品网站| 欧美成人在线免费视频| 免费成人黄色| 免费在线一区二区| 欧美精品免费在线| 欧美片网站免费| 国产精品国产福利国产秒拍| 欧美午夜无遮挡| 国产精品免费观看视频| 国产精品视频xxxx| 国产日韩欧美视频| 国产一二三精品| 极品尤物av久久免费看| 狠狠色狠狠色综合日日五| 亚洲欧洲另类| 亚洲视频精选| 国产欧美日韩三级| 久久久精品五月天| 久久久久一区二区三区| 久久男女视频| 欧美日本国产视频| 国产精品久久久久久久久久妞妞| 国产精品v欧美精品v日本精品动漫 | 久久久噜噜噜久久中文字幕色伊伊|