473,503 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy a Structure

Hi ,
in C, How do I copy a contents of a Structure pointer to a Structure
Variable. e.g
struct A var1;
struct A *Var2;

I want to copy contents of Structure pointed to by Var2 to a Structure var1.
Is there any standard library function to do the same?

Thanks and Regards,
Nov 17 '05 #1
3 1229
Hi Pravin!
in C, How do I copy a contents of a Structure pointer to a Structure
Variable. e.g
struct A var1;
struct A *Var2;


var1 = *Var2;

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #2
Thanks Jochen,
var1=*var2 will copy the contents of structure pointed
to by var2 into var1. One more thing I wanted to ask was how do I copy the
contents of the structure var1 into the structure pointed to by var2?
var2=&var1 will make var2 point to the var1 struture.

thanks again,

"Jochen Kalmbach [MVP]" wrote:
Hi Pravin!
in C, How do I copy a contents of a Structure pointer to a Structure
Variable. e.g
struct A var1;
struct A *Var2;


var1 = *Var2;

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Nov 17 '05 #3
Pravin Prabhu <Pr**********@discussions.microsoft.com> wrote:
Thanks Jochen,
var1=*var2 will copy the contents of structure pointed
to by var2 into var1. One more thing I wanted to ask was how do I copy the
contents of the structure var1 into the structure pointed to by var2?
var2=&var1 will make var2 point to the var1 struture.
*Var2 = var1;
thanks again,
Schobi
[...]


Schobi

--
Sp******@gmx.de is never read
I'm Schobi at suespammers dot org

"Coming back to where you started is not the same as never leaving"
Terry Pratchett
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3448
by: Anna | last post by:
Hi all. I am trying to write a stylesheet that will structure the input HTML file in the following way: For each heading of level n it needs to enclose the heading and all its content until the...
4
612
by: Stephan Tobies | last post by:
Hi everyone, I am looking for a good data structure that could be used to represent families of trees with shared sub-trees and copy-on-write semantics. On a very abstract level, I would like...
15
38045
by: Sourcerer | last post by:
Hi all. Can I do this to duplicate the contents of struct a in struct b struct myStruct a, b, *aptr, *bptr; aptr = a; bptr = b; Do something to initialize contents of structure a...
1
2232
by: Brad | last post by:
Using vb.net, I am attempting to copy a byte array buffer to a structure but need to specify an offset, in bytes, from the top of the structure. I have studied the Marshal class but it appears I...
4
12433
by: Dennis | last post by:
I have several Data Structures, say "mystruct" which contain arrays of bytes, other structures, etc. I then dimension a variable (var1) as "mystruct" and set the various elements var1 to data. I...
7
2721
by: Just Me | last post by:
I know (or at least think) the following is not correct. The comment says what I want to do, but I think the code will copy the data not the address. Is this one of the things that can't be...
4
5156
by: Férnas | last post by:
Hey guys, In my app, I have a DataTable named "dta"... If i create a new variable of DataTable type named "dta2", and assign the dta as value, it creates a reference to dta, then, when I make...
19
5694
by: ivan.leben | last post by:
Let's say I have a piece of allocated memory which I want to expand and reuse if possible or allocate in a different part of RAM if resizing is not possible, however, in the latter case I don't...
7
2138
by: pereges | last post by:
which one do you think is better ? I need to make my program efficient and in some places I have passed the copy of a variable which makes life some what easy while writing huge expressions but...
0
7198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.