Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions struct_code.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>
int main(){

struct xyz{

int x;
};

struct xyz obj1={1}; //creating struct object
struct xyz obj2= obj1; //Copy of that object

printf("%d",obj2.x); //access using copy
obj2.x=100; //changing value using copy object
printf("%d",obj1.x); //access value using original object
return 0;
}
//Expected output:
1
100