|
neodeaths wrote: if i wanted to find the size of the array which is pointed by the pointer for my struct.
how should i go about it?
Keep that number in a global variable of some sort.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
yes i know that but i am just checking if there is a way to find the memory size of the whole array pointer?
if i could i could probably do a array_mem_size/sizeof(struct people)
|
|
|
|
|
neodeaths wrote: if i could i could probably do a array_mem_size/sizeof(struct people)
This would only work for stack-based memory, not heap-based memory allocated with malloc() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
by the way i realise something wielrd when i i malloc to make the array have a size of 10.
and i try to access the 15th array by hardcoding the program still works do you know y?
|
|
|
|
|
neodeaths wrote: do you know y?
Without seeing a code snippet, no.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Perhaps you want something like this:-
<br />
person* aPersons = new person[iCount];<br />
delete [] aPersons;<br />
Now you have an array of person structs and can use e.g. aPersons[iIndex].member to access a person in the array.
A more modern approach is to use container classes which dynamically size themselves. There are loads of these in the standard library std::list and std::vector are worth a look.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Read the first line of his message: he is doing C programming, not C++
|
|
|
|
|
neodeaths wrote: could anyone show me how to do a dynamic memory allocation on struct which can free me of having to state the array size?
i read some ebook saying i could use malloc but so far they used malloc on the string instead of struct.
thanks.
i prefer, stl::list/std::vector for this type of effort
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You fell into the same trap as Matthew Faithful - he's using C, not C++.
Otherwise, I'd totally agree with you.
Iain.
|
|
|
|
|
Iain Clarke wrote:
You fell into the same trap as Matthew Faithful - he's using C, not C++.
he he he! people is just forgetting difference between c and c++
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I developed an application with VC6. I used a lot of resouce in my application, such as images, xml configuration files, lang strings files, and so on. To protect my resoure from being seen or modified by user directly, I need a way to hide or package these resource.
Does anybody have some good idea about this? Thanks in advance.
Peter
|
|
|
|
|
Peter, Chan wrote: developed an application with VC6. I used a lot of resouce in my application, such as images, xml configuration files, lang strings files, and so on. To protect my resoure from being seen or modified by user directly, I need a way to hide or package these resource.
you coukld save that in password protected zip file, when your program start running, unzip on temp location, after completetion of task remove the files or update the zip if require!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi Friends,
I just want to write an Outlook Add-on,which automatically reads from a list of Quotes(the quotes are placed in a text file Quotes.txt) and places at the end of my signature randomly. This should happen
each time i compose a mail.
I have gone through several articles in CP,but nothing helped me.
Can somebody help me out in sending some good links about Outlook automation.
Thanks
Appu..
"Never explain yourself to anyone.
Because the person who likes you does n't need it.
And the person who dislikes you won't believe it."
|
|
|
|
|
|
Thanks for the Help Dave.
But I am more interested in writing code for outlook automation.
Can you please help me out,how can i approach.
Thanks again,
Appu..
"Never explain yourself to anyone.
Because the person who likes you does n't need it.
And the person who dislikes you won't believe it."
|
|
|
|
|
NiceNaiduCan you please help me out,how can i approach.
I know a little of Office Automation, but not to the level which you desire. Good luck.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I'm using VC++ 2005, and have a Solution with 5 projects. I also have a common library on my computer which contains 20+ headers and 20+ .cpp files (no .lib files or .dll, all are source codes only). I have set the default path for include in VS2005 pointing to my library folder. My questions are
1. When i create a new project (in the same solution), i have to add all the .h and .cpp from my library manually in to the project. Without adding the .cpp, it would not link. If i have 5 projects, i would have to do that 5 times. Anyway to avoid this?
2. Because 5 projects are sharing the same set of library (.h, .cpp), whenever i do a full rebuild of the solution, the library files get built 5 times, each time for every project. This takes a long time, how can i just compile the common files just once to save time, and all projects can use them?
Thanks
|
|
|
|
|
I think that the best solution would be to make a library (I mean, a real .lib file) out of what you call your "library files". That way you don't need to include your source files in the other projects and they will be compiled only once.
|
|
|
|
|
Is there no other way? What about pre-compiled headers? Can i share between projects?
|
|
|
|
|
What's the problem with using a library file ? That's really simple to do.
I don't know any other easier solution (never really used a lot pre-compiled headers).
|
|
|
|
|
Because most of the files are dependent on each other, making library file is a headache. Like, CoreImage.h depends on Core.h and CoreTypes.h, while CoreFilter.h depends on CoreImage.h, Core.h, CoreTypes.h etc. I would then need to update the build order, post build events etc. Afterall, all the library files keep changing as well (in development).
That's why i try to avoid making lib.
|
|
|
|
|
I don't understand the problem. All those files are the files that you call 'library files', right ? And they don't depend on any of your other project files ?
Then, there is no problem. When you will change any of the lib file, the library will be recompiled, which will then imply that all the projects that depends on this library will get relinked with it.
The only thing you need to make sure is that the header files are accessible to all of the other projects and that the lib file is also accessible to the other projects.
|
|
|
|
|
I understand. You're right. Thanks, i think i need to make libs.
|
|
|
|
|
----- 已跳过生成: 项目: circ ------
------ 已跳过生成: 项目: circprops ------
========== 生成: 0 成功或最新,0 失败,2 被跳过 ==========
what is the meaning? it appear when i compile the code down from the msdn
|
|
|
|
|
已跳过生成:
项目已跳过生成
Born to win...!
|
|
|
|