|
Hi,
That's very simple. When you increment amount pointer, you actually change its address, which is not valid when you call delete.
You can do something like this to avoid its modification (in main):
...
long *ptr = amount;
for (int i = 0; i < 5 ;++i,++ptr) {
cout<< *ptr << endl;
}
delete [] amount;
...
Regards
|
|
|
|
|
Thank you, but i still get the same error.
Thanks & Regards,
Dhana
|
|
|
|
|
jana_dhana wrote: for (int i = 0; i<5 ;++i)
{
cout<< amount[i] <<endl;
}< blockquote="">
Why you need to increment address?As you need to delete it.Use indexing instead.
jana_dhana wrote: a[k] = new long;
Whats this for ?
I've modified your code like this,
#include "iostream.h"
#include "iomanip.h"
#include <vector>
void fun(long **a);
int main(int argc, char* argv[])
{
long *amount = NULL;
fun(&amount);
for (int i = 0; i<5 ;i++)
{
cout<< amount[i]<<endl;
}
delete [] amount;
return 0;
}
void fun(long **a)
{
*a = new long[5];
std::vector<int> var;
var.push_back(5);
var.push_back(6);
var.push_back(65);
var.push_back(58);
var.push_back(57);
std::vector<int>::iterator i;
int k = 0;
for(i= var.begin();i != var.end();++k, ++i)
{
(*a)[k] = *i;
}
}
-- modified at 10:57 Friday 13th October, 2006
-- modified at 10:58 Friday 13th October, 2006
|
|
|
|
|
i get the same errors with the above code also.
Thank you.
Thanks & Regards,
Dhana
|
|
|
|
|
Oh ! posted wrong code.
See modified code above now.
|
|
|
|
|
jana_dhana wrote: fun(&amount);
fun() is expecting a pointer to a pointer to a long . However, you are calling it with just a pointer to a long .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Nope, he's calling fun with a pointer to a pointer. amount is defined as pointer.
Regards
|
|
|
|
|
You're right. My bad.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi everyone,
when we want to create a MFC application whats different between
Use MFC in a shared DLL and Use MFC in a static library
Thanks
|
|
|
|
|
messages wrote: Use MFC in a shared DLL and Use MFC in a static library
Usual method is Use MFC in shared dll. In which, MFC dlls are loaded in exe's address space at run time.
By this method executable size is less. But you need to ship all required dll's wherever you want to run your executable.
Second method is usually bad idea, because it makes your executable size large. In that case, you doesn't need to carry dependent dlls with executable.
|
|
|
|
|
See the second question here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Iam working On the Help files. So iam using Htmlhelp function and accessing a "****.Chm " file.
But Problem is I need to go to specific Topic ( or page ) of that .chm file.
Iam giving Sample code.
your guidence is so helpful to me.
void CTestHelpDlg::OnHelp()
{
// TODO: Add your control notification handler code here
HtmlHelp(m_hWnd, "proengineer.chm", HH_DISPLAY_TOPIC, NULL);
}
|
|
|
|
|
|
that is to open only Help file. But I need specific topic in the .chm file
|
|
|
|
|
Krishnatv wrote: HtmlHelp(m_hWnd, "proengineer.chm", HH_DISPLAY_TOPIC, NULL);
You need to further qualify the second argument to include the name of the topic, like:
HtmlHelp(m_hWnd, "proengineer.chm::/maintopic.htm", HH_DISPLAY_TOPIC, NULL);
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I want to add some text data into avi file. How can I achieve this? I am not getting how to set format for text file using "AVIStreamSetFormat" function. How can I add some text data into avi file?
Regards,
Hemant.
|
|
|
|
|
Do you want to make avi or modify avi?
|
|
|
|
|
Hi,
I want to make AVi from some images which I achived. Now I wants to add some text data into avi file How I can do this?
Regards,
Hemant
|
|
|
|
|
I think best example is on MSDN it makes a avi file with numbers 0..9 it doesnt any bmp file although you can insert your bmp files to it but I think (not sure)you can find it on VC6 exmples
|
|
|
|
|
You need to put the text onto your images, and THEN make them into an AVI.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I think it may be a bit more complicated than it seems to be.
In the simplest form I would do something like this:
- decompress avi to a raw frame by frame format,
- draw text on every such frame,
- compress back to original format.
I doubt there a specific function for this task.
Regards
|
|
|
|
|
Yes
I neew to draw some text on images. For that reason I ned to save some text data in avi file. How can i do this?
|
|
|
|
|
What you call 'text' is in fact not text: it's just an image with certain pixels coloured so that you (as a user) can interpret it as text.
It is way more complicated that you think. You cannot just open the file and write your text somewhere in it so that magically your text will appear in the images.
If you want to do it by code, I think you can forget about it (or spend really a lot a lot of time, I even don't know if this is possible). The best solution is what you have been told: do it with a tool that lets you open the images one by one and draw the text yourself manually with the tool on the image. Then save everything after it.
|
|
|
|
|
In every "advanced" movie authoring software, such operation can be described exactly as:
-decompress to frames
-draw text on every frame (for specified time in stream of course)
-apply filters
-compress
Regards
|
|
|
|
|
Hi,
Thanks to all who replied /answered my queries. I solved my problem with some R and D. Actually my intention was to save some text data into AVI file.(text data means some xml file specific to my application). As we know we can save bitmap audio and text data in AVI file I was used same method as image for text with only format change like FOURCC code 'txts' instead of 'vids' etc.
If I need any more help I will again post a new question as always
Thanks again for all replies
Regards,
Hemant.
|
|
|
|