This commit is contained in:
CK Tan 2020-11-01 17:55:33 -08:00
parent 84fd6725e0
commit 6e1f2e3db8

View file

@ -31,18 +31,16 @@ FILE* fp;
toml_table_t* conf;
char errbuf[200];
/* Open the file. */
/* Open the file and parse content */
if (0 == (fp = fopen("path/to/file.toml", "r"))) {
return handle_error();
}
/* Run the file through the parser. */
conf = toml_parse_file(fp, errbuf, sizeof(errbuf));
fclose(fp);
if (0 == conf) {
return handle_error();
}
fclose(fp);
/* Alternatively, use `toml_parse` which takes a string rather than a file. */
conf = toml_parse("A null terminated string that is TOML\0", errbuf, sizeof(errbuf));