...
| Code Block | ||
|---|---|---|
| ||
FILE* f;
const char *editor;
char *file_name;
/* initialize file_name */
f = fopen(file_name, "r");
if (f == NULL) {
/* Handle fopen() error */
}
/* ... */
editor = getenv("EDITOR");
if (editor == NULL) {
/* Handle getenv() error */
}
if (system(editor) == -1) {
/* Handle Error */
}
|
...
| Code Block | ||
|---|---|---|
| ||
FILE* f;
const char *editor;
char *file_name;
/* initialize file_name */
f = fopen(file_name, "r");
if (f == NULL) {
/* Handle fopen() error */
}
/* ... */
fclose(f);
f = NULL;
editor = getenv("EDITOR");
if (editor == NULL) {
/* Handle getenv() error */
}
/* Sanitize environment before calling system()! */
if (system(editor) == -1) {
/* Handle Error */
}
|
...