For debugging purposes, I find it useful to display the contents of data structures. (In Python for example, I would just do "print some_dict_name").
Can this be achieved in C this easy too by using a standard library, or do I have to implement this myself depending on the data structure ?
Consider the following code, where I have to iterate over the StructArray again to display all of its contents.
#include <stdio.h>
struct SomeStruct {
int id;
};
int main() {
struct SomeStruct StructArray[10];
int x = 0;
for (x = 0; x < 10; x++) {
StructArray[x].id = x;
}
for (x = 0; x < 10; x++) {
printf("StructArray[%d].id = %d\n", x, StructArray[x].id);
}
return 0;
}