Hi all,

I'm trying to create a function that finds a key=value pair in a file and returns the value part for the given key. EG, if test.conf contains the text "port=10", I need a function to which I can hand "port" and get "10" returned to me.

I've got this far:-

Code:
char * getStringFromConf(char searchkey) {
	char c[120];
	FILE *f;
	f = fopen(CONF_FILE_PATH, "r");
	while ( fgets(c, 120, f) != NULL ) {
		char *sep = "=";
		char *key, *value;
		key = strtok(c, sep);
		value = strtok(NULL, sep);
		}
	}

	fclose(f);
}
... and the core of this works fine outside of a function (I wrote a quick and dirty test for that).

I'm unsure where to go from here in terms of matching the key variable with searchkey, and then returning the value variable as an appropriate type.

Can the experts here help?

Many thanks.