diff --git a/examples/C/grib_clone.c b/examples/C/grib_clone.c index d54ab4440..c2964b54a 100644 --- a/examples/C/grib_clone.c +++ b/examples/C/grib_clone.c @@ -68,7 +68,7 @@ int main(int argc, char* argv[]) CODES_CHECK(codes_get_message(clone_handle, &buffer, &size), 0); /* write the buffer to a file */ if (fwrite(buffer, 1, size, out) != size) { - perror(argv[1]); + perror(argv[2]); return 1; } codes_handle_delete(clone_handle); diff --git a/examples/C/grib_precision.c b/examples/C/grib_precision.c index ae39318b2..4f3657610 100644 --- a/examples/C/grib_precision.c +++ b/examples/C/grib_precision.c @@ -116,7 +116,7 @@ int main(int argc, char** argv) /* write the buffer in a file*/ if (fwrite(buffer, 1, size, out) != size) { - perror(argv[1]); + perror(outfile); exit(1); } diff --git a/examples/C/grib_set_keys.c b/examples/C/grib_set_keys.c index feea6731a..50aeff372 100644 --- a/examples/C/grib_set_keys.c +++ b/examples/C/grib_set_keys.c @@ -78,7 +78,7 @@ int main(int argc, char** argv) /* write the buffer in a file*/ if (fwrite(buffer, 1, size, out) != size) { - perror(argv[1]); + perror(outfile); exit(1); } diff --git a/examples/C/grib_set_missing.c b/examples/C/grib_set_missing.c index 82f698975..98395c120 100644 --- a/examples/C/grib_set_missing.c +++ b/examples/C/grib_set_missing.c @@ -77,7 +77,7 @@ int main(int argc, char** argv) /* write the buffer in a file*/ if (fwrite(buffer, 1, size, out) != size) { - perror(argv[1]); + perror(outfile); exit(1); } diff --git a/examples/C/grib_set_pv.c b/examples/C/grib_set_pv.c index 7ca4c32fe..e279aec8b 100644 --- a/examples/C/grib_set_pv.c +++ b/examples/C/grib_set_pv.c @@ -78,7 +78,7 @@ int main(int argc, char** argv) /* write the buffer in a file*/ if (fwrite(buffer, 1, size, out) != size) { - perror(argv[1]); + perror(outfile); exit(1); }