c++

Assigning char value in one array to char value in another array

Sounds easy, but I've got a bug and I'm not sure what's causing it? nopunccount = 0; char *ra = new char[sizeof(npa)]; while (nopunccount <= strlen(npa)) { ra[nopunccount] = npa[strlen(npa) - nopunccount]; nopunccount++; } ra never gets a value into it and I have verified that npa has char values to provide within the nopunc...

Checking if an iterator references an item in a list

Hey, i just want to check, if the iterator points on an object in a list. What's the cmd? Thank you. :) SkyThe EDIT: Hmm,.. ok i tried it. Now there is a Error: "Expression: list iterators incompitable" Maybe some code: #include <list> list<obj> list; list<obj>::iterator it; if(it != list.end()){ //here the error pops up when i ...

How to represent this "tree" data?

Ive got some data (not that the data actually exists until after I solved this...) I need to be able to manipulate within my program. However I cant work out a suitable structure for storing this in. The data represents a set of paths and nodes. There is one input (which may in some cases no be present) then a number of paths between no...

Converting a char array to something that can be appended to a ostringstream

std::ostringstream parmStream; char parmName[1024]; THTTPUrl::Encode(parmName, pParm->Name().c_str(), 1024); //I want to add the value of the paramName to the parmStream worked b4 when parmName was a string but obv not now parmStream << "&" << parmName + "="; Gives me the following .. error: invalid operands of types \u2018char ...

How to build a static C++ library using Xcode ?

Hello guys, I am trying to create a static library in Xcode using C++ ( All my files are .h or .cpp ). I tried deleting main.cpp and then adding a target to my project to build a "Static" library. Since I'm not using Cocoa, I assumed that I needed to add a BSD Static Library, but I have tried other static library options with no apparen...

fetching blob data from sybase

Hello all my question is about sybase's ct_get_data() function i got below message when fetching TEXT data that is is not the last column of the result set. Open Client Message: Message number: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER = (61) Message String: ct_get_data(): user api layer: external error: Item of 1 is not greater th...

Variable naming convention according to scope (class, method, global...)

Hello all, I soon started a small C++ project and elaborated some naming convention rules for variables, according to scope. I made class members _prefixed_with_underscore and methods parameters suffixed_with_underscore_. I soon got neurotic about inventing naming conventions for everything, like global variables (ok, those might be im...

vector assignation on uninitialized memory chunk and similar issues

vector<vector<string> > test for example. g++, you can do test.reserve(10); test[0] = othervector; test[9] = othervector; It doesn't crash. Theory says you shouldn't do it like that because you are assigning a vector to a chunk of memory that believes it is a vector. But it works just like the next one: #include <string> #include <...

Controlling USB Access of Windows CE6

I am looking to find a way to programatically (C++) control/secure access to the USB ports on a Windows CE device that will only have a single login, and then be left running a real-time application. Ideally, being able to have a password entered into the running application, which then opens up/enables USB functionality, would be the e...

Hosting the CLR: IHostAssemblyStore::ProvideAssembly causes exception " exception "The located assembly's manifest definition does not match the assembly reference"

Hi, PostSharp 2.0 includes a CLR host and implements IHostAssemblyStore::ProvideAssembly. From managed code, I invoke: Assembly.Load("logicnp.cryptolicensing, Version=3.0.0.0, Culture=neutral, PublicKeyToken=4a3c0a4c668b48b4") My implementation of IHostAssemblyStore::ProvideAssembly receives the following input for ...

No match for call to '(std::pair<unsigned int, unsigned int>) (unsigned int&, unsigned int)'

I don't know what's wrong with the follwing code, it should read numbers and put their value with the position together in a vector of pairs and then sort them and print out the positions. I removed the part with sort - i thought the problem was there, but i received an error on compilation again. #include <iostream> ...

Calling virtual functions inside member functions

I'm reading Thinking in C++ by Bruce Eckel. In Chapter 15 (Volume 1) under the heading "Behaviour of virtual functions inside constructor", he goes What happens if you’re inside a constructor and you call a virtual function? Inside an ordinary member function you can imagine what will happen – the virtual call is resolved a...

Why can't I create a std::stack of std::ifstreams?

Why does the following not work: #include <iostream> #include <fstream> #include <stack> std::stack<std::ifstream> s; -PT ...

Does anyone have an easy solution to parsing Exp-Golomb codes using C++ ?

Trying to decode the SDP sprop-parameter-sets values for an H.264 video stream and have found to access some of the values will involve parsing of Exp-Golomb encoded data and my method contains the base64 decoded sprop-parameter-sets data in a byte array which I now bit walking but have come up to the first part of Exp-Golomb encoded dat...

Input stream iterators and exceptions

I was playing around with istream iterators and exception handling a few days ago and I came across with this curiousity: #include <iostream> #include <fstream> #include <iterator> #include <algorithm> using namespace std; int main(int argc, char* argv[]) { if (argc < 2) { cout << argv[0] << " <file>" << endl; return -1...

Questions Regarding the Implementation of a Simple CPU Emulator

Background Information: Ultimately, I would like to write an emulator of a real machine such as the original Nintendo or Gameboy. However, I decided that I need to start somewhere much, much simpler. My computer science advisor/professor offered me the specifications for a very simple imaginary processor that he created to emulate first....

How do I store the value of a register into a memory location pointed to by a pointer ?

I have the following code: void * storage = malloc( 4 ); __asm { //assume the interger 1 is stored in eax mov eax, storage //I've tried *storage as well but apparently it's illegal syntax } /* other code here */ free(storage); However, in the code, when I dereference the storage pointer ( as in *(int *)storage ), I do not ge...

Does anyone know what the "-FC" option does in gcc g++?

Does anyone know what the "-FC" option does in g++? I have it in my SConstruct script that builds the command line g++ command, I have searched google ...

If I allocate memory in one thread in C++ can I de-allocate it in another

If I allocate memory in one thread in C++ (either new or malloc) can I de-allocate it in another, or must both occur in the same thread? Ideally, I'd like to avoid this in the first place, but I'm curious to know is it legal, illegal or implementation dependent. Edit: The compilers I'm currently using include VS2003, VS2008 and Embedd...

Is there a way to get an event from windows on every new process that is started?

Hi I want to get a notification each time a new process is started by the operating system. Note that I need to that in native code (I know it can be done in managed code using System.Management members). Extra points if there is a way to get it before the process starts running :) (i.e in during its initialization) Thanks. ...