|
You'd keep track of the allocated length of items yourself. (Yes, it's annoying that you can't get the allocated length in C++, even though it's available to library code.)
|
|
|
|
|
Or use any standard containers like std::vector rather than plain arrays.
|
|
|
|
|
Use the STL deque[^]
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
If you just want to use a queue, then the STL already has one[^].
If you're doing this for a learning experience, then the first thing to learn is that C/C++ arrays a) are not easily resizable and b) do not track their own length. If you want to do this with arrays, then you'll need to reallocate arrays when they get too small (remembering to copy all the elements to the newly resized array) and also keep track of the number of allocated and used array elements. Or you could use an STL container like a vector in place of the array.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi
I have a MDI application. How can I get the number of the "CMDIChildWnd" initialized?
Thanks
|
|
|
|
|
|
Hi all,
I am wondering if we can get sourcecode information when an exception occurs. I understand we need debug symbols to get actual source file and line number, but is there a way I can get a unique identifiers that describe the source file and linenumbers where the crash occured - somethng from the dissembly of the callstack? Microsoft must be doing this internally, but is this information available for external developers? Your help is very much appreciated.
Nachiket
|
|
|
|
|
Well, unfortunately if your using Visual Studio 2005 or higher then you need to parse the PDB to obtain the line number in a Release build. Unless you want to add __LINE__ macros[^] all over your code...
This may help:
Retrieving Symbol Information by Address[^]
If you are using Visual Studio 2003 or below you can use the /MAPINFO:LINES linker option. This will create a MAP file which contains symbolic names, address offsets and even line numbers at the bottom. When an exception occurs all you needed to do was walk the list of line numbers and compare the address of the exception to the ones in the list.
I dont really know why they removed the /MAPINFO:LINES option but I suspect it has something to do with VS2005 optimizations.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks David. That was really helpful information.
|
|
|
|
|
Hello. I'm writing a program using M$ Visual C++. Is there a simple API for getting the file size? Something like GetFileSize? I'm trying to read out bytes from a binary file, and I think it's prematurely reading out an EOF character. So, I need to query the filesize from the OS. Thanks.
|
|
|
|
|
pcpro178 wrote: Is there a simple API for getting the file size? Something like GetFileSize?
You mean something like GetFileSize()[^]? Yeah, there is.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Well, yes, but GetFileSize requires a variable of type HANDLE to be passed to it. I have a FILE variable instantiated, but how do I go from one to the other?
|
|
|
|
|
If you insist on the FILE pointer, you can do this:
fseek(file, 0, SEEK_END);
filesize = ftell(file);
fseek(file, 0, SEEK_SET);
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
There are multiple ways including the following simplified code (will not compile):
FILE* pFile = fopen();
if (pFile)
{
int fileNum = _fileno(pFile)
HANDLE hFile = (HANDLE) _get_osfhandle(fileNum);
GetFileSize(hFile);
}
|
|
|
|
|
Thanks! This was a huge help!
|
|
|
|
|
I need to draw an image that is able to zoom in many times, the image in question is of a city. Currently I am drawing the image using a .bmp file, the problem is when I zoom in too much I get the blocky, pixelation associated with .bmp files. I would like some suggestions, ideas, tutorials, etc. on what I should do to keep the fidelity of the image a any zoom level. Should I use a paging scheme for the drawing, is it possible to draw some vector based image or I there something else I should be looking into? General info: drawing using MFC GDI functions, the current image size is around 100 mb. Thanks in advance for any guidance.
|
|
|
|
|
I suggest you try PhotoShop first to resize your image smaller for multiple times.
If PS can not do it well, you should give up.
Or you may need to use jpg format to zoom in your image - zoom in with jpg is better than bitmap format.
|
|
|
|
|
includeh10 wrote: zoom in with jpg is better than bitmap format
Really, have you tried it?
It's the same, except now you have jpg artifacts all over the place.
|
|
|
|
|
includeh10 wrote: zoom in with jpg is better than bitmap format
neither format has any influence on the ability to zoom on the final image. after decoding either, you get an array of pixels - and pixels are pixels, regardless of where they came from.
|
|
|
|
|
tealomp wrote: the problem is when I zoom in too much I get the blocky, pixelation associated with .bmp files
that's not BMP files, that's just what you get when you zoom in on a raster-based image. at some point, there's just not enough information in the original file to zoom in any further - there's no way to interpolate any more data between the source pixels and you end up magnifying the source pixels themselves. this is true regardless of the source of the image or the algorithm used to zoom (though some algorithms are better than others).
tealomp wrote: what I should do to keep the fidelity of the image a any zoom level
there is no way to do such a thing with a raster-based image.
on the other hand, vector-based images can scale to any size. or, you could do something like MrSID, which is an image format that blends images of multiple resolutions to allow for smooth zooming over a large range. it's used primarily for satellite data.
|
|
|
|
|
when i programming this night, i come up against some difficulties.
i use c-free 4.1
let's see the program first:
=========================================================
#include<iostream.h>
#define PI 3.141529
void main()
{
float radius;
float area = 2*radius*PI;
cout << "Plz input the radius:\n";
cin >> radius;
cout << "The area is " << area << endl;
}
=========================================================
so, very easy right! but, something happens:
i input 40
when i debug first time , the window shows the area is -56116.4
when i debug second time, it shows -7.19607e-35
oh!!my god!!
whats happen?
as i know, the right count is 251.32232
someone help me plz!
|
|
|
|
|
#include <iostream>
using namespace std;
#define PI 3.141529
void main()
{
float radius;
cout << "Plz input the radius:\n";
cin >> radius;
float area = 2*radius*PI;
cout << "The area is " << area << endl;
}
Best wishes
Nuri
|
|
|
|
|
Why do you calculate the area before asking the radius to the user ? Of course it doesn't work because your radius variable is not initialized properly...
|
|
|
|
|
In this universe, the area of circle is calculated r^2*pi and not 2*r*pi .
I can't believe nobody screamed yet
|
|
|
|
|
As long as radius is 2, what's the big deal?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|