I just started learning the C language. I have a good history with C# and Java though.
#include <stdio.h>
#include <stdlib.h>
#include "info.h"
int main()
{
int day = 24, month = 3, year = 2016;
char name[] = "Ahmad\0";
strcpy(name, "Ahmad(strcpy-ed string)\0"); // <-- LINE 8
printf("%s made this program on %d-%d-%d\n", name, day, month, year);
return 0;
}
As you can see the values have been assigned to day, month and year. But the problem is the output has competely different values. The output is this
Ahmad(strcpy-ed string) made this program on 1920234272-1684352377-1885565556
What's more interesting is if i delete line 8 it works properly. Why is this happening?