64,641
社区成员
发帖
与我相关
我的任务
分享
char ln[100];
FILE *f;
f=fopen("xxx.ini","r");
while (1) {
if (NULL==fgets(ln,100,f)) break;
if (ln[0]==';') {
printf("Comment Line:%s",ln);
} else {
printf("Line:%s",ln);
}
}
fclose(f);
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
FILE* ini;
char* name;
char* value;
char line[81];
ini = fopen("19.txt", "r");
if(ini == NULL)
{
return -1;
}
while(!feof(ini))
{
fgets(line, 80, ini);
name = strtok(line, "=");
value = strtok(NULL, "=");
if(name && value)
{
value[strlen(value) - 1] = '\0';
printf("[name=%s, value=%s]\n", name, value);
}
}
return 0;
}