Answer the question
In order to leave comments, you need to log in
How to assign a value to data in a C structure?
struct tableI
{
char name[4];
float doctor[16];
float bunk[16];
}с;
// нужно чтоб name - был масивом со строками, с данными {РСФСР, Украина, Латвия, Эстония}. ДАнные менятся не будут, просто для хранения.
// а все остальные массивы с числами.
Answer the question
In order to leave comments, you need to log in
Perhaps there is a solution here: https://learnc.info/c/structures.html
#include<stdio.h>
struct tableI
{
char *name[4];
float doctor[16];
float bunk[16];
} tableI;
int main()
{
struct tableI a;
a.name[0] = "РСФСР";
a.name[1] = "Украина";
a.name[2] = "Латвия";
a.name[3] = "Эстония";
// и т.д. ...
printf("%s|%s|%s|%s", a.name[0],a.name[1],a.name[2],a.name[3]);
}
What did you find so terrible in structures compared to ordinary arrays not in structures?
c.doctor[0] = 3.14;
c.doctor[15] = 6.28;
c.bank[5] = 0;
strcpy(& c.name[0], "Yes");
typedef struct NODE NODE;
typedef struct NODE* PNODE;
typedef struct DLIST DLIST;
typedef struct DLIST* PDLIST;
struct NODE {
int key;
int info;
PNODE prev, next;
}node;
struct DLIST {
int count, size;
PNODE left, right;
}list;
int main () {
nd->key = 1; // Ключ узла для поиска, удаления и т.п.
nd->info = 1996; // Информация узла
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question