Following code iterates through many data-rows, calcs some score per row and then sorts the rows according to that score:
unsigned count = 0;
score_pair* scores = new score_pair[num_rows];
while ((row = data.next_row())) {
float score = calc_score(data.next_feature())
scores[count].score = score;
scores[count].doc_id = row->...
In a Win32 GUI application I need to determine the width of area occupied by a string on a toolbar button so that I adjust the button width accordingly. The toolbar is plain old ToolbarWindow32 windows class. I use the following code:
HDC dc = GetDC( toolbarWindowHandle );
SIZE size;
GetTextExtentPoint32( dc, stringToMeasure, tcslen(...
Does C++ stl have a standard time class? Or do I have to convert to c-string before writing to a stream. Example, I want to output the current date/time to a string stream:
time_t tm();
ostringstream sout;
sout << tm << ends;
In this case I get the current date/time written out as a number without any formatting. I can use
c- runtime...
Please see the following code and its output - please explain me the code
void abc(int);
class A
{
public:
A()
{
cout<<"Constructor Called";
}
~A()
{
cout<<"Destructor called";
}
};
int main()
{
try
{
abc(-1);
}
catch(int p)
{
cout<<p<<endl;
}
return 0;
}
void a...
[EDIT] I changed the source as suggested by Stephen Martin (highlighted in bold). And added the C++ source code as well.
Hi,
I'd like to call an unmanaged function in a self-written C++ dll. This library reads the machine's shared memory for status information of a third party software. Since there are a couple of values, I'd like to ...
I was given some code in which some of the parameters are pointers, and then the pointers are dereferenced
to provide values. I was concerned that the pointer dereferencing would cost cycles, but after looking at
a previous StackOverflow article: http://stackoverflow.com/questions/431469/how-expensive-is-it-to-dereference-a-pointer-in-c...
Hi,
I'm using Opencv's K-means implementation to cluster a large set of 8-dimensional vectors. They cluster fine, but I can't find any way to see the prototypes created by the clustering process. Is this even possible? OpenCV only seems to give access to the cluster indexes (or labels).
If not I guess it'll be time to make my own imple...
Short problem:
#include <iostream>
using namespace std;
int main()
{
double **T;
long int L_size;
long int R_size = 100000;
long int i,j;
cout << "enter L_size:";
cin >> L_size;
cin.clear();
cin.ignore(100,'\n');
cout << L_size*R_size << endl;
cout << sizeof(double)*L_size*R_size << endl;
...
I'm working with the Android NDK, and since it does not currently support the STL, I was wondering if there are any brilliant people out there who have had success with this, or know which is better suited for the Android platform: uSTL or STLPort.
Thanks!
EDIT:
Looks like another option may be CrystaX .NET.
From their website:
....
Strangely I had this working before but I reinstalled my system, upgraded to w7 and now I can't seem to get this code to compile.
The problem is that I'm using winhttp.h in most of my application, but I have a simple FTP client object that I wrote using wininet.h functionality. I can't seem to get the application to compile now, no matt...
How do you output \ symbol using cout?
...
I was a bit staggered today by the sheer number of auto generated includes that Boost produces when doing a compile if we turn on verbose includes. We're averaging 3000 header files included per compilation unit and sometimes getting up to 5000. Virtually all of it is caused by Boost's preprocessor-meta programming funk with large numb...
I am working with 1gb large tiff images of around 20000 x 20000 pixels. I need to extract several tiles (of about 300x300 pixels) out of the images, in random positions.
I tried the following solutions:
Libtiff (the only low level library I could find) offers TIFFReadline() but that means reading in around 19700 unnecesary pixels.
I i...
Do I really need Visual studio to build c/C++ application on Windows.
Is there any way to have makefiles and get the application built.
...
Here's a quick and easy question: using GDI+ from C++, how would I load an image from pixel data in memory?
...
This question is an offgrowth of my previous question on creating a hash table to store string keys and pointers as data. I'm getting a seg fault post-construction when I try to add entries to my hash table. I'm still very confused about what syntax is appropriate.
I currently have (thanks to previous posters):
// Simulation.h
#include...
I was looking at Qt example here:
and inside the constructor, they have:
Window::Window()
{
editor = new QTextEdit(); // Memory leak?
QPushButton *sendButton = new QPushButton(tr("&Send message")); // Memory leak?
connect(sendButton, SIGNAL(clicked()), this, SLOT(sendMessage()));
QHBoxLayout *buttonLayout = ne...
Consider the following example:
int size = 10, *kk = new int[size];
for (int i = 0; i < size; i++) {
kk[i] = i;
}
delete [] kk;
How can I add a watch for the whole array? I can add a watch one by one (kk[0],*kk[1]*...), but since I know the array's length is there a way to do it automatically? I mean something like kk[0..size-1]...
I have been unable to find any decent documentation on this function. The code base I am working with uses a function from winuser.h called LoadStringW which takes as arguments: (HINSTANCE hInstance, UINT uID, LPWSTR lpBuffer, int cchBufferMax).
What is this function? What is it for? When might it return 0?
...
I'm writing a program on a Linux platform that is generating text files that will be viewed on, inevitably, a Windows platform.
Right now, passing std::endl into a ostream generates the CR character only for newlines. Naturally, these text files look wrong in MS Notepad.
1) Is there a way to change std::endl such that it uses CR+LF f...