Last active
May 12, 2016 10:02
-
-
Save groyoh/a792fdbf62be1b013fbc477b2a62eead to your computer and use it in GitHub Desktop.
Memcpy example
This file contains hidden or 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
| /* Taken from http://www.cplusplus.com/reference/cstring/memcpy/ */ | |
| #include <stdio.h> | |
| #include <string.h> | |
| typedef struct { | |
| char name[40]; | |
| int age; | |
| } Person; | |
| int main () | |
| { | |
| Person yor = (Person){ .name = "Yohan", .age = 22 }; | |
| Person clone; | |
| memcpy ( &clone, &yor, sizeof(yor) ); | |
| printf ("Clone: %s, %d \n", clone.name, clone.age ); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment