3 ms·
I've started to do the same for C arrays, leaving the plural as the name for its paired count: User *user = ...; int users = ...; for (int i =
by mtklein 3y ago
I've started to do the same for C arrays, leaving the plural as the name for its paired count:
User *user = ...;
int users = ...;
for (int i = 0; i < users; i++) {
user[i] = ...;
}
This also used to be the Google convention for naming repeated fields in Protocol Buffers, so that the generated code would read like `add_user()` and not `add_users()`, though it seems like that has changed?
- theonething 3y agoThat doesn't make sense to me. The array is a collection of users, so `users` makes more sense to me. And what you are calling users is `totalUsers` or a variant of that.
- Ferret7446 3y agoWell, it's technically just a pointer to a user in C...
- theonething 3y agoAn array in C is a pointer to a block of memory consisting of a contiguous sequence of memory chunks of the same type. So in this context, it's pointing to a list of users, not just one.