- #include <</SPAN>stdio.h>
- #include <</SPAN>unistd.h>
- #include <</SPAN>fcntl.h>
- #include <</SPAN>string.h>
- #include <</SPAN>malloc.h>
- #include <</SPAN>stdlib.h>
- typedef struct item_t {
- char *key;
- char *value;
- }ITEM;
- /*
- *去除字符串右端空格
- */
- char *strtrimr(char *pstr)
- {
- int i;
- i = strlen(pstr) - 1;
- while (isspace(pstr[i]) && (i >= 0))
- pstr[i--] = '\0';
- return pstr;
- }
- /*
- *去除字符串左端空格
- */
- char *strtriml(char *pstr)
- {
- int i = 0,j;
- j = strlen(pstr) - 1;
- while (isspace(pstr[i]) && (i <</SPAN>= j))
- i++;
- if (0<</SPAN>i)
- strcpy(pstr,&pstr[i]);
- return pstr;
- }
- /*
- *去除字符串两端空格
- */
- char *strtrim(char *pstr)
- {
- char *p;
- p =strtrimr(pstr);
- return strtriml(p);
- }
- /*
- *从配置文件的一行读出key或value,返回item指针
- *line<
嵌入式 linux读取按行读写文本文件
最新推荐文章于 2023-03-13 21:53:30 发布