Hi all,
let's say that we have a program. In that program you just put characters and then push ENTER - for example "PUT character, ENTER , PUT character, ENTER, PUT character, ENTER, etc...". And after each ENTER, the program puts the pressed character into a "STRING".
So if my inputs were:the output STRING would be:Code:'f' ENTER 'y' ENTER 'a' ENTER 'k' ENTERCode:"fyak"
AND HOW TO DO IT? --> I wanted to do it by creating a "STRING of CHAR" (or ARRAY of CHAR) and then make for it a "DYNAMIC ALLOCATION" of memory (but I don't know WHICH CODE I should use to dynamic allocation - it's something with MALLOC(), but I don't know what exactly...).
AND NOW MY QUESTION IS: --> It is possible to create an ARRAY that will be changing its size DURING the program running according to the situation (because before the starting of the program I don't know HOW BIG array I should create, because I don't know how many CHARACTERS I will add to the string)?
---> AND NOW TO MY MAIN PROBLEM: <---
==================================
I have read that the function (for example for the type INT) "sizeof(int)" will return to me some number --> and that number should be the "SIZE OF INTEGER" --> AND THIS TERM I DON'T UNDERSTAND.
I understand that the concrete NUMBER (or character), for example the number "6369" needs in program some amount of memory (for example "20 BYTES", ...I know, it's probably a wrong number but it doesn't matter), but HOW BIG MEMORY DOES THE TYPE "INT" (or "char" or "real") NEED??? --> it's JUST ONLY a TYPE, and NOTHING CONCRETE (like '6369').
==================================
So if someone could explain to me, what does this mean:
Code:sizeof(<something>)
I have studied "C" just one semester at university, so I would appreciate simple answers --> something that I will be able to imagine.
But thanks very much for every answer.
Petike.