So I'm trying to copy part of an array into another array in the simplest way possible. I was trying to avoid using a loop. This was my thought process...
char date[]="20140805";
char year =date[0..3];
The ".." is what is causing the error. I want to be able to break up the date variable into parts, and was hoping to be able to do so compactly in one line like this. Some help would be appreciated.
You should not use a loop.
char year[5];
char date[] = "20140805";
memcpy(year, date, 4);
year[4] = 0;
that's how you should do it, or may be you want
char date[] = "20140805";
char year[] = {date[0], date[1], date[2], date[3], 0};