Storing text/data charr array string

Hello, I've been playing around with the ps/2 keyboard library, And what I'd want to do is that I want to Store what I type I'd preferably want to store it in Such a way that each string/array is 16 chars long. Could you all help me out with this? I've been doing some research on the matter but all I found so far is string manipulation, So what I guess I am saying is that I want to make Strings while typing, All I've seen is that you have to define a string before you use it, And with Arrays, I don't have that much experience, So if you know something then a example piece of code would be nice :)

The keyboard is Read in this way:

if (keyboard.available()){
char c = keyboard.read();
}

and if I press a key c changes into the char of the key I pressed. So if I want to store it in array then I'd have to store char c, then increment 1 place(go one place to the right) and have it do that every time char c changes. I hope you all can help me out with this :)

Greets, Duality.

Where do you want to store it? Does it have to be persistent through power cycles? Look up about the built in EEPROM

I made this for one of my projects, it might help out:

class CircularBuffer {
    public:
        CircularBuffer();
        void put(unsigned char c);
        void del();
        unsigned char get();
    private:
        static const uint8_t _size = 10;
        uint8_t _in, _out;
        char _buffer[_size];
        unsigned char increment(unsigned char);
        unsigned char decrement(unsigned char);
};
CircularBuffer::CircularBuffer() {
    _in = _out = 0;
}

inline unsigned char CircularBuffer::increment(unsigned char c) {
    return (c==_size-1)? 0 : c+1;
}

inline unsigned char CircularBuffer::decrement(unsigned char c) {
    return (c==0)? _size-1 : c-1;
}

void CircularBuffer::put (unsigned char c) {
    _in = increment(_in);
    //If _in == _out (we've wrapped around), delete the last value
    if (_in == _out) _out = increment(_out);
    _buffer[_in] = c; //Write c to buffer
}

void CircularBuffer::del () {
    //If there's anything in the buffer, move _in back
    if (_in != _out) _in = decrement(_in);
}

unsigned char CircularBuffer::get () {
    //If there's nothing in the buffer, return 0
    if (_out == _in) return 0;
    //Else, increment _out and return value
    _out = increment(_out);
    return _buffer[_out];
}

Wizend I'll look at it as I don't understand the code at this time :) but with a little study I'll get it done :) Where I want to store it is in the flash, want to avoid EEPROM since i am going to write and rewrite it alot of times. I've got some external data storage laying around might be able to use that? and as for persistence through power cycles? help me out here I am still kinda of a newbie... If it means that the data stays stored after power is lost then no not really needed

Where I want to store it is in the flash,

That's compile-time only, I'm afraid.

want to avoid EEPROM since i am going to write and rewrite it alot of times.

Writing to flash, if it were possible is more restrictive on read / write cycles than EEPROM.

At run time you can only write to flash that is in the other bank. That is the boot loader bank and everything else.

Hmm good to know, is it possible to store the strings in memory that is attached later on? like a Ram chip or something Would that be possible?

Hmm good to know, is it possible to store the strings in memory that is attached later on? like a Ram chip or something
Would that be possible?

Yes, it would. Only slightly more difficult that storing on the internal EEPROM.

But if the external memory is SRAM then you loose the contents on a power cycle. If it is an EEPROM then why not use the internal stuff?

hmm, I've been experimenting around with reading from SD, and makes text files, maybe this is a idea, only problem i have is that my SD reader doesn't work yet.

Eureka! got it working :) reading from SD, now how to implement this in storing the data I type on the keyboard onto the SD, but I'll be looking later into that as for now I am just real tired.