| | |
monolithic copying
![]() |
•
•
•
•
Originally Posted by sunnypalsingh
When a structure is assigned, passed, or returned, the copying is done monolithically....what does this monolithic mean
any example??
For example, this C code:
C Syntax (Toggle Plain Text)
#include <stdio.h> struct cat { int id_num; int age; int HP; int MP; }; int main(void) { struct cat x; struct cat y; x.id_num = 1; x.age = 2; x.HP = 3; x.MP = 4; y = x; /* Now y.id_num == 1, y.age == 2, ... */ printf("%d %d %d %d\n", y.id_num, y.age, y.HP, y.MP); /* Prints "1 2 3 4\n" */ return 0; }
All my posts may be redistributed under the GNU Free Documentation License.
•
•
•
•
Originally Posted by sunnypalsingh
What about pointers...anything pointed by pointers???.....if possible by example
C Syntax (Toggle Plain Text)
struct dog { type_1 val_1; type_2 val_2; type_3 val_3; . . . type_n val_n; };
The expression "x = y;", where x and y are of type struct dog, could be written as the following:
C Syntax (Toggle Plain Text)
x.val_1 = y.val_1; x.val_2 = y.val_2; x.val_3 = y.val_3; . . . x.val_n = y.val_n;
So pointers would get copied, yes. They would contain the same memory address.
Remember that in C++ (but not C), structures can have copy constructors, which change this.
All my posts may be redistributed under the GNU Free Documentation License.
![]() |
Similar Threads
- End of an Era? DVD copying threatened. (Geeks' Lounge)
- JProgressBar while file copying (Java)
- shallow copying (Java)
Other Threads in the C Forum
- Previous Thread: C Sockets
- Next Thread: type conversion
Views: 1745 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C
api array arrays behaviour binary binarysearch c++ calculator changingto char character code coke command conversion convert creafecopyofanytypeoffileinc database decimal directory dude dynamic error exec factorial fgetc fgets file fork forloop frequency function functions givemetehcodez grade graphics homework i/o incrementoperators input insert int integer lazy line linked linkedlist linux list lists loop loopinsideloop. malloc matrix measuring memory mysql no-code no-effort open opensource operator output path pointer pointers printf problem process program programming question read recursion recursive recv reverse scanf scripting send sms_speak socketprograming spoonfeeding stdout steganography string strings strtok structures student syntax system turbo-c turboc undefined unix user variable whileloop windows






