I made this to just seal in strcpy()
to my brain, and I noticed that if I leave the brackets empty the compiler says it needs an initializer or needs a specified value to compile. However I can put any value into the brackets and it still compiles. Even with a zero... But if the strcpy()
function adds a string terminator to whatever string is declared, why would I still need to put a placeholder in the brackets?
Code below...
#include <stdio.h>
#include <string.h>
main()
{
char yearFirst[0]; <------ HOW DOES THIS still EXECUTE??
char yearSecond[6];
char month[5];
/* when declaring strcpy function, place each copied string before.
their desired print function.
or else the print function will print thr same strcpy for each print
function proceeding it.
ex.
strcpy(yearFirst, "Sept., Oct., Nov., Dec., Jan.");
strcpy(yearSecond, "Mar., Apr., May., Jun. Jul., Aug.");
followed by:
printf("These months have 1-31 days: %s\n\n", yearFirst)
printf("These months have 1-30 days: %s\n\n", yearSecond);
output will equal both statements saying
"These months have 1-31: sept oct ...."
"these months have 1-30: sept oct....."
*/
strcpy(yearFirst, "Sept., Oct., Nov., Dec., Jan.");
printf("These months have 1-31 days: %s\n\n", yearFirst);
strcpy(yearSecond, "Mar., Apr., May., Jun. Jul., Aug.");
printf("These months have 1-30 days: %s\n\n", yearSecond);
strcpy(month, "Feb.");
printf("%s has 1-28 days\n", month);
return 0;
}