473,467 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is struct() equivalent to ZeroMemory() ?

For some code I copied off of MSDN it uses the Cism of

OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));

I was wondering if
OPENFILENAME ofn = OPENFILENAME();
is equivalent for all cases of a structure?

Would this also asign pointers a value of NULL (which this structure does
use, pointers).

Or should I just stick with the Cism of ZeroMemory for a structure that can
be used in C and C++
Aug 25 '07 #1
2 2655
On Aug 25, 2:38 pm, "Jim Langston" <tazmas...@rocketmail.comwrote:
OPENFILENAME ofn = {sizeof(OPENFILENAME}};

although I think some people would use

OPENFILENAME ofn = {sizeof(ofn)};

Not sure which is prefered, but I generally use the
class/structure name in sizeof instead of an instance.
I can't think of any rational reason why you would use the
former. Can you enlighten me?

Aug 27 '07 #2
"Old Wolf" <ol*****@inspire.net.nzwrote in message
news:11**********************@q4g2000prc.googlegro ups.com...
On Aug 25, 2:38 pm, "Jim Langston" <tazmas...@rocketmail.comwrote:
> OPENFILENAME ofn = {sizeof(OPENFILENAME}};

although I think some people would use

OPENFILENAME ofn = {sizeof(ofn)};

Not sure which is prefered, but I generally use the
class/structure name in sizeof instead of an instance.

I can't think of any rational reason why you would use the
former. Can you enlighten me?
You can't think of any rational reason to use the sizeof the class, or the
sizeof the instance?
Aug 28 '07 #3

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

Similar topics

0
by: Josiah Carlson | last post by:
Good day everyone, I have produced a patch against the latest CVS to add support for two new formatting characters in the struct module. It is currently an RFE, which I include a link to at the...
3
by: sathyashrayan | last post by:
The standard confirms that the following initialization of a struct struct node { --- --- } struct node var = {NULL};
67
by: S.Tobias | last post by:
I would like to check if I understand the following excerpt correctly: 6.2.5#26 (Types): All pointers to structure types shall have the same representation and alignment requirements as each...
60
by: Mohd Hanafiah Abdullah | last post by:
Is the following code conformat to ANSI C? typedef struct { int a; int b; } doomdata; int main(void) { int x;
15
by: stand__sure | last post by:
Having recently had a need to use ZeroMemory from the kernel32.dll, I "discovered" that there is apparently no .NET equivalent to the c/c++ sizeof operator -- one does exist in the Marshall...
5
by: Martin Jørgensen | last post by:
Hi, Consider this code: --- beginning of code --- #include <iostream> using namespace std; class Child{ public:
7
by: Alex | last post by:
If I have two struct. See below: struct s1 { int type; int (*destroy)(struct s1* p); } struct s2 { struct s1 base;
9
by: werasm | last post by:
Hi all, What is the difference between: typedef struct { ... } MyS1; ....and...
24
by: Grey Alien | last post by:
If I have the ff struct: struct A { unsigned int i; char s; } a, b; And use them in code like this:
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.