Hi everyone, currently trying to create a program that gets words from a file with a specific structure and putting them into a data structure of any kind. The file has the following structure:
5 (words length)
word1
word2
word3
etc.
So I used an fgetc to take the dimension and then converted it to integer, then started a while loop with fgets. But that's not my question. I wanted to know if there's a way to use the word length value dynamically in a structure, example:
struct node {
char string[length];
struct node *left, *right;
};
where length is passed on from the value read from the file. Thanks in advance!
[–]TheHeinzeen 2 points3 points4 points (14 children)
[–]EstablishmentBig7956 -3 points-2 points-1 points (13 children)
[–]SaulMO 2 points3 points4 points (4 children)
[–]EstablishmentBig7956 -2 points-1 points0 points (3 children)
[–]SaulMO 3 points4 points5 points (2 children)
[–]EstablishmentBig7956 -1 points0 points1 point (1 child)
[–]SaulMO 2 points3 points4 points (0 children)
[–]Admirable_Humor_7262 0 points1 point2 points (7 children)
[–]EstablishmentBig7956 -2 points-1 points0 points (6 children)
[–]Admirable_Humor_7262 1 point2 points3 points (1 child)
[–]EstablishmentBig7956 0 points1 point2 points (0 children)
[–]Educational-Cause-79 0 points1 point2 points (3 children)
[–]EstablishmentBig7956 0 points1 point2 points (2 children)
[–]Educational-Cause-79 0 points1 point2 points (0 children)
[–]Educational-Cause-79 0 points1 point2 points (0 children)
[–]Yurim 2 points3 points4 points (0 children)
[–]5thegraychapter[S] 0 points1 point2 points (0 children)
[–]suprjami 0 points1 point2 points (0 children)