2010年12月27日 星期一

變數靈異事件

#include <stdio.h>
#include <string.h>
int main(void)
{
  char source[] = "This is a string.";
  int i = 5;
  char destination[4];
  strcpy(destination, source);
  printf("i is %d\n", i);
  printf("source is [%s]\n", source);
  printf("destination is [%s]\n", destination);
  return 0;
}
The output.
i is 544434464
source is [a string.]
destination is [This is a string.]

1 則留言: