I fail in first steps of my program. First of all i need to read from file into a struct array. I fail at doing that - i get lots of errors and i got a feeling that my syntax in reading is not right at Once I do this i will be able to carry on with my program. I think that I have to use calloc / realloc / free and all of those strange thing because my data file might have very long set of digits.
My data file:
4 5 5 6
9
5 7 6 9
6 5
1 8 1 2 3 6 5
1 9
4 5 5 6
9
5 7 6 9
6 5
1 8 1 2 3 6 5
1 9
it has to be read like coordinates (x ; y) - doesn't matter how these numbers are placed - i can/must jump and read
Your use of
calloc
is not correct. As Herman has stated in his comment, callingcalloc
returns a pointer to the block of memorysizeof(struct Trikampiai)
bytes long; you are storing a pointer in an int. Also, you never use the character arraybuf
.Try:
struct Trikampiai *Trikamp = calloc(1, dydis);
if you want to dynamically allocate the memory, or just keepstruct Trikampiai Trikamp;
if you want automatic allocation. From what I can tell of your program's intention you are confusing these two concepts of memory allocation (stack vs heap). This is a good resource: What and where are the stack and heap?i.e.
Trikamp->xas = sk;
vsTrikamp.xas = sk
With the former you have to access the structure by using the
->
operator, while the latter requires the.
operator, which is what I think you are wanting.What other errors are you seeing?