Questions tagged "c++" (page No.1)

Calculating relative time

Given a specific DateTime value, how do I display relative time, like 2 hours ago 3 days ago a month ago etc...? ...

Getting Field value for a given coordinate out of ESRI Shapefile using GDAL/OGR

I have a bunch of ESRI shapefiles that contain Land Cover data across Canada (provided by Geobase). I need to query the files and obtain the value of a certain field (called COVTYPE) in a given location specified either by lat/lon or UTM coordinates. I can open a ...

OpenGL bug only present when run without debugging, how is it possible?

I'm having a strange bug when writing a tiny OpenGL application. When I run the application with F5 (w/Debugging) in Visual Studio, it runs well. If I run it with Ctrl + F5 (w/o Debugging), it runs at 0 FPS. In both cases I'm using the "Release" build in Visual ...

need API for send log messages to server

is there API in C/C++ that enable to send log messages reliable? better if it cross platform something like client side: SEND_LOG(192.168.1.12,"file opened"); server side string s=RECEIVE(); ...

Using select() for nonblocking serial

I'm working on a project in which I need to read and write data from a serial port, and this needs to be non-blocking for reasons I won't go into. The select() function looks like what I want to use, but I'm struggling with getting a working implementation. ...

Qt close a running window through code

I have a program that opens another window and i want the old window to close. Is there some function or something that would close the window through the code but keep the other window running? ...

boost asio service queue deepness and policies

I understand a running asio service is like a queue I can use to post tasks a thread will execute sequentially. However, as any queue, I guess there are limits. Is it possible to set this limit for asio services? Is it possible to set what policy to follow when ...

Printing a pointer with <iostream>

Why does #include <iostream> using namespace std; int main() { cout << (char*)0x10 << endl; } segfault, but #include <iostream> using namespace std; int main() { cout << (void*)0x10 << endl; } seems to work just fine? ...

Expected object construction is missing

class A { public: A () { wcout << L"Empty constructed." << endl; } A (LPCWSTR Name) : m_Name(Name) { ...

Numeric header compiling fails

Just a few minutes ago i was introduced to std::accumulate. And it needed #include <numeric> to function. But the compiling of the numeric header fails! Here is the compile log, i dont know what more info to supply, the application im writing this in is too big to include here, but ...

How to prohibit NULL being passed in an argument list when std::string is the parameter?

So I ran into a bug today where a NULL was passed into a constructor's argument list and this caused the application to break. Its odd that the compiler did not prohibit this from happening. Since the argument list changed, the problem was not noticed until now. See the following ...

MISTY1 key schedule

I am trying to implement MISTY1. It's RFC, RFC2994, contains psuedocode that I basically copy and pasted into Code::Blocks. However, I managed to mess that up somehow. I am pretty sure my mistake is in the key scheduling (section 2.2), since I managed to get incorrectly encrypted data ...

For loop not getting executed

I have the following code snippet in which I'm trying to print some statements into an XML file: void parseXML::writeStruct(std::fstream& abc,std::string prnt) { for (map<string,struct structSet>::iterator it = structData.begin();it != structData.end();it++) { if (((it->second.parent.compare("")==0) && (it->second.written == false))) ...

MSBuild, unresolved externals and Visual Studio 2005

I am attempting to use msbuild to build a Visual Studio 2005 solution. The batch file I am using is: @ECHO OFF SETLOCAL set VSDIR=C:\Program Files (x86)\Microsoft Visual Studio 8 set VCVARSALL=%VSDIR%\VC\vcvarsall.bat call "%VCVARSALL%" x86 && ^ msbuild path\to\my.sln ^ /v:normal ^ /p:Configuration=Release ^ /p:Platform=Win32 ^ ...

declaration of static function outside of class is not definition

I am getting this error when I compile with GCC: error: declaration of 'static int utils::StringUtils::SplitString(const std::string&, const std::string&, std::vector<std::basic_string<char> >&, bool)' outside of class is not definition Code: Header: namespace utils { /* * This class provides static String utilities based on STL library. ...

Array declaration and size initialization (C++)

I'm not exactly sure how to pose this question so I'll start with some example code: //header file class A { public: A(); private: int x; std::string arr[x]; } //cpp file class A { public: A() { /*code to get the ...

Getting last N segments of URL in C++

I need to write a function to return the last N segments of a given URL, i.e. given /foo/bar/zoo and N=2, I expect to get back /bar/zoo. Boundary conditions should be handled appropriately. I have no problem doing it in C, but the best C++ version I could come up ...

How to (manually) align cells in C/C++?

When I was testing my application, it crashed. And after debugging it took me to this piece of code: static cell AMX_NATIVE_CALL n_fblockwrite(AMX *amx, cell *params) { cell *cptr; cell count; amx_GetAddr(amx,params[2],&cptr); if (cptr!=NULL) { ...

Time-out for Threads in Boost using Posix Time

I have created a number of threads in C++ using the Boost Threads library, I want to time-out all these threads, I can use the timed_join() in a loop, but this can make the total waiting time = number-of-threads * time-out-time. for(int i = 0; i < number_of_threads; ++i) { threads[i]->timed_join(boost::posix_time::seconds(timeout_time)); } So, ...

« Previous12345678910 ... 70627063Next »Show All