Thanks Salem/Elysia - sorry, I was being slow earlier (late night ).
Now I have:-
Code:
int getStringFromConf(const char * searchkey, char *resultValue, size_t resultSize) {
int result = 0;
char c[120];
FILE *f;
f = fopen(CONF_FILE_PATH, "r");
if (f != NULL) {
while ( fgets(c, 120, f) != NULL ) {
char *sep = "=";
char *key, *value;
key = strtok(c, sep);
value = strtok(NULL, sep);
if ( (value != NULL) && (strcmp(key, searchkey) == 0) ) {
//strcpy(resultValue, value); <-- causes a bus error
resultSize = strlen(value);
printf("Value : %s", value);
printf("Size : %d", resultSize);
result = 1;
}
}
fclose(f);
} else {
result = -1;
}
return result;
}
But the strcpy I'm trying to do (currently commented out) is causing a bus error. I'm not sure why as I believe the pointer to char is the correct type for it (according to the man page)?
Thanks...