Make the generator options accept a file name in addition to format string.
[apps/agl-service-can-low-level.git] / tests / test_encode1.c
index c5131e4..742c99f 100644 (file)
@@ -22,11 +22,12 @@ int main()
     /* Now encode it and check if we succeeded. */
     if (pb_encode(&stream, Person_fields, &person))
     {
-        fwrite(buffer, stream.bytes_written, 1, stdout);
+        fwrite(buffer, 1, stream.bytes_written, stdout);
         return 0; /* Success */
     }
     else
     {
+        fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream));
         return 1; /* Failure */
     }
 }