changing a string after it been declared .

Having problem doing what should be simple:-

Trying to making a simple alarm clock, But having problem doing what should be simple:- changing a string after it been declared .

I use a string “bcd_string” which is use in a function, that turns the string into 3 digit BCD used for the clock - rtc_bcd[0] - to - rtc_bcd[2]

How do you put a new string into bcd_string array.

Tried strcpy("12:00:00" , bcd_string ); and can`t use bcd_string[]=”12:12:12” without a error.

Not sure how to do this :-

char bcd_string[]="12:47:28";
int rtc_address = B1101000;
int rtc_bcd[7];
int rtc_dec[3];
void setup()
{

void int_alarm()
{
strcpy("12:00:00" , bcd_string );
Serial.println(bcd_string);
string2bcd();

bcd_string[]="12:12:12";

ooops

strcpy("12:00:00" , bcd_string );

close but yet so far away .

o.k it should ( bcd_string , "12:12:12 )

strcpy(destination, source) -- yours was backwards.

Warning when using strcpy() - when you declare the character array to hold the string declare it to be long enough to hold the longest string it will ever hold. Otherwise when you do a strcpy() of a longer string into the character array you're going to go past the end of the memory reserved for that string and corrupt something else in memory and it will end in tears.

void setup()
{
  Serial.begin(9600);
  char foo[] = "hi";
  Serial.println(foo);
  
  strcpy( foo, "bye" ); // BAD WRONG PAIN CORRUPTING DATA 

}

thanks ...

My thinking is the wrong way around , but I guess it is logical.

So far I know what I`m putting into the string so I know the size to the byte . are I wrong have to error check or get more byte to the string .
But that is so hard to do when you have so little of them .

Running out of ram faster than the eprom / program.

char bcd_string[]="12:23:45";
int rtc_address = B1101000;
int rtc_bcd[7];
int rtc_dec[3];

boolean alarm_set[3];
int alarm_on[3][3];
int alarm_off[3][3];

you can guess this eats up the ram space.

For a clock the important thing is to recognize that:

char time[]="12:00:00"; // Start the clock at 12

is cool, but that this will be bad:

char time[]="1:00:00"; // Start the clock at 1
strcpy( time, "12:00:00" ); // This is the bad case I was warning you about

I set it up with - bcd_string[]="12:23:45"

Which is the max than will be put inside it .

untill I get a 12:12:123 by mistake