c++

C C++ array.... need help understanding code

Can you please explain this code? It seems a little confusing to me Is "a" a double array? I would think it's just an integer, but then in the cout statement it's used as a double array. Also in the for loop condition it says a<3[b]/3-3, it makes no sense to me, however the code compiles and runs. i'm just having trouble understanding it...

How to identify blog engine ?

I am writing a search engine whose purpose it is to search all kind of blogs for specific kinds of content. I'm particularly focusing on these blogs engines: Blogger LiveJournal MySpace Open Diary Tumblr TypePad Windows Live Spaces Wordpress.com Xanga Now my question is: Is there any way I can use google to find links that are from a s...

Dock a control in native C++

I know how to do this in .Net but in native Win32, how does one dock a control. I'm trying to dock a trackbar I made like vlc's trackbar. Thanks dock it to the bottom of its parent window ...

What is useful about a reference-to-array parameter?

I recently found some code like this: typedef int TenInts[10]; void foo(TenInts &arr); What can you do in the body of foo() that is useful, that you could not do if the declaration was: void foo(int *arr); // or, void foo(int arr[]); // or, void foo(int arr[10]); // ? I found a question that asks how to pass a reference to an ...

map vs. hash_map in C++

Hi, I have a question with hash_map and map in C++. I understand that map is in STL but hash_map is not a standard. What's the difference of them two? Any insights are strongly welcomed. Thanks! ...

How can I get the username of the person executing my program?

How can I get the username of the process owner (the user who is executing my program) in C++? ...

implicit promotion to avoid overflow in std::partial_sum

This code suffers from overflow because the type of intermediate results does not depend on the destination type: vector< uint8_t > increments; … vector< uint32_t > increasing( increments.size() ); partial_sum( increments.begin(), increments.end(), increasing.begin() ); However, so does this (GCC 4.2): partial_sum( increments.begin()...

How to check open processes in C++?

In Windows I would like the C++ command or reference that would get the "tasklist" in C++ and output it to a buffer? ...

How to port forward in C++?

I have a sockets program that requires port 1002 to be open and I wanna know how to port forward in C++ on windows so i may use this port freely? ...

a c++ Google chrome event listener

can anyone help me on how to connect to google chrome. i would like to build a standalone c++ application(probably a dll) that would list events done by the browser.Probably like the BHO implementation of IE. can anyone give the first thing or steps to do about it?! thanks alot:) help much appreciated PS: i already have known that go...

Simple File I/O in C++ - Never Exits This Loop?

Hi, I'm a programming student in my second OOP class, my first class was taught in C# and this class is taught in C++. To get our feet wet in C++, our professor has asked us to write a rather large program with File I/O. The problem is, I have a small part of my program that is not working, at least, not for me. The project requires tha...

Should I use a function in a situation where it would be called an extreme number of times?

I have a section of my program that contains a large amount of math with some rather long equations. Its long and unsightly and I wish to replace it with a function. However, chunk of code is used an extreme number of times in my code and also requires a lot of variables to be initialized. If I'm worried about speed, is the cost of cal...

Double to int conversion behind the scene?

I am just curious to know what happens behind the scene to convert a double to int, say int(5666.1) ? Is that going to be more expensive than a static_cast of a child class to parent? Since the representation of the int and double are fundamentally different is there going to be temporaries created during the process and expensive too. ...

Can all keys be represented as a single char in c++?

I've searched around and I can't seem to find a way to represent arrow keys or the escape key as single char in c++. Is this even possible? I would expect that it would be similar to \t or \n for tab and new line respectively. Whenever I search for escaped characters, there's only ever a list of five or six well known characters. ...

C++ STL Memory Allocator Compile Error

I'm writing a C++ custom allocator for use with STL. When I put the following code in the class definition, it compiles: #include "MyAlloc.hpp" #if 1 template <typename T> typename MyAlloc<T>::pointer MyAlloc<T>::allocate(size_type n, MyAlloc<void>::const_pointer p) { void *ptr = getMemory(n*sizeof(T)); typename MyAlloc<T>::pointe...

Where is pointer metadata stored?

Could be that I am overlooking something obvious, but where is pointer metadata stored? For instance if I have a 32-bit int pointer ptr and I execute ptr++ it knows to advance 4 bytes in memory. However, if I have a 64-bit int pointer it knows to advance 8 bytes. So who keeps track of what type of pointer ptr is and where is it stored? F...

Using boost::random and getting same sequence of numbers

I have the following code: Class B { void generator() { // creating random number generator boost::mt19937 randgen(static_cast<unsigned int>(std::time(0))); boost::normal_distribution<float> noise(0,1); boost::variate_generator<boost::mt19937, boost::normal_distribution<float> > nD(randgen, noise); for (i...

Looking for a C or C++ library providing a functionality similar to Google Go's channels

...for use in a multithreaded network server. I want to pass data around between multiple threads. Currently I'm using sockets, with the master thread blocking on select() and workers blocking on recv(), though I feel there probably are more advanced or prepackaged ways of handling this task in C++. ...

None in boost.python

I am trying to translate the following code d = {} d[0] = None into C++ with boost.python boost::python::dict d; d[0] = ?None How can I get a None object in boost.python? ANSWER: boost::python::dict d; d[0] = boost::python::object(); ...

What does C4250 VC++ warning mean?

What does C4250 Visual C+ warning mean in practical terms? I've read the linked MSDN page, but I still don't get what the problem is. What does the compiler warn me about and what problems could arise if I ignore the warning? ...