Created
January 19, 2011 15:54
-
-
Save photex/786345 to your computer and use it in GitHub Desktop.
see what happens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
int main(int argc, char* argv[]) { | |
char *src="12345678"; | |
char dst1[10]; | |
char dst2[10]; | |
// ensure that dst is clean | |
memset(dst1, '\0', 10); | |
memset(dst2, '\0', 10); | |
strcpy(dst1, src); | |
strncpy(dst2, src, 8); | |
printf("Source: %s\nResult 1: %s\nResult 2: %s\n", src, dst1, dst2); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment