- 4,663
- 36
Is defining a structure template the same as defining a structure variable?
thanks.
thanks.
The discussion revolves around the differences between defining a structure template and a structure variable in C and C++. Participants explore the concepts of structure templates, structure variables, and their initialization, particularly in the context of an assignment involving account information.
Participants generally agree on the distinction between structure templates and structure variables, but there is no consensus on the use of the term "template" in the context of the assignment. The discussion remains unresolved regarding the specific interpretation of the assignment's requirements.
Participants express uncertainty about the assignment's wording and the technical definitions of templates versus structs, indicating potential limitations in understanding the task.
#include <stdio.h>
int main()
{
struct info //definition of the info structure template
{
int owner_account_num;
char owner_street_address[35];
char owner_city_state[35];
char owner_zip[6];
float owner_account_balance;
float owner_credit_limit;
// struct info * pointer_to_instance;
};
struct info typical_account = {
1001001001, "129 Maple Street","Tampa FL","90903", 7.345, 9.99
};
printf("%d, %s, %s, %s, %f, %f \n", typical_account.owner_account_num,
typical_account.owner_street_address, typical_account.owner_city_state,
typical_account.owner_zip,typical_account.owner_account_balance,
typical_account.owner_credit_limit);
// printf("Pointer value: ");
return 0;
}
typedef struct thingy_tag {
int someNumber;
char* aBigOlString;
void* secretDataNoPeeking;
double whoPutThisHere;
} thingy;
Yes, e.g.:Math Is Hard said:Thanks, plover. Can I initialize theThingy the same way I initialized the structure values?