c++

How do I create new directory asp.net in c++ for window form button click

I would like to know how to create folder in c++ for asp.net System::IO::IsolatedStorage::IsolatedStorageFile isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User); isoFile->CreateDirectory() I have created windows form in c++ with a button. When I click on the button it should take a ...

Learning C++ : Which book is out of date ?

SO . I want to learn C++ .I didn't read any book on C++. Some people talk about "modern C++" and C++ programming with C influence. So which book is completely out of date? ...

segmentation fault in overloading operator =

Hi, I just got a seg fault in overloading the assignment operator for a class FeatureRandomCounts, which has _rects as its pointer member pointing to an array of FeatureCount and size rhs._dim, and whose other date members are non-pointers: FeatureRandomCounts & FeatureRandomCounts::operator=(const FeatureRandomCounts &rhs) { i...

How do I convert C/C++ string with escape character to a plain (raw) string

The function prototype would be: string f (string s); or char* f (char* s); f would transform a string represented by printable ascii char into a raw string. and it would behaves as in the following examples: f("AAA") = "AAA" f("AA\n") = "AA+line_feed" i.e the input string is 4 char long (+ NULL), the output is 3 char long(+NUL...

Specializing a template by a template base class

I'm writing a template for which I'm trying to provide a specialization on a class which itself is a template class. When using it I'm actually instanciating it with derivitives of the templated class, so I have something like this: template<typename T> struct Arg { static inline const size_t Size(const T* arg) { return sizeof(T); }...

Controlling access to output in multi-threaded applications

I have an application that creates a job queue, and then multiple threads execute the jobs. By execute them, I mean they call system() with the job string. The problem is that output to stdout looks like the output at the bottom of the question. I would like each application run to be separated, so the output would look like: flac 1.2...

View function template instantiations

I have a simple function template: #include <iostream> using namespace std; template <class T> T GetMax (T a, T b) { T result; result = (a > b) ? a : b; return (result); } int main () { cout << GetMax<int>(5, 6) << endl; cout << GetMax<long>(10, 5) << endl; return 0; } The above example will generate 2 function template ...

Why does valgrind say basic SDL program is leaking memory?

Here is the SDL program: #include <SDL/SDL.h> int main(int argc, char** argv){ SDL_Init(SDL_INIT_VIDEO); SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE); SDL_Quit(); return 0; } Compiled with the command: g++ -o test test.cpp -lSDL And here is the output of valgrind: christian@christian-laptop:~/cpp...

why is my 3n+1 problem solution wrong?

I have recently started reading "Programming Challenges" book by S. Skiena and believe or not I am kind of stuck in the very first problem. Here's a link to the problem: 3n+1 problem Here's my code: #include <iostream> #include <vector> #include <algorithm> using namespace std; unsigned long calc(unsigned long n); int main() { ...

How does Gedit expose its api to python for plugins?

I'm starting a medium (academic) project in C++ for which I need users to be able to write small scripts, which interact directly with the main program. My first thought as an aproach to this was to make something like Gedit does with it's plugins (in fact I thought about it because it is something very similar to what I need to do.) I ...

what is the error in this code ..

in the code below i m trying to reverse the string there is no compile time error but ,nothing is displayed .what is wrong ? string string1="arunachalam"; void reverseStr() { for(int i=string1.length();i<0;i--) { cout<<string1[i]; } } ...

Cast native pointer to a C++\CLI manged object reference?

hi, I have a callback that is called through a delegate. Inside it I will need to treat the buffer data that arrive from a record procedure. Normaly in a unmanaged context I could do a reinterpret_cast on dwParam1 to get the object reference. But in a manged context how can I cast a DWORD_PTR to a managed object ref? static void Wav...

Event Handling for Dynamically Created Activex Control

Hello, The scenario: I have a TabCtrl in which I plan to place 1 ActiveX Control (myActXCtrl) in each Tab. The number of Tabs can increase dynamically. Hence, I have to create a new instance of ActiveX Control (myActXCtrl) each time and place it in the newly created Tab (I have done till this point successfully). The problem: Th...

C++ comparing c string problem

I have written the following code which will does not work but the second snippet will when I change it. int main( int argc, char *argv[] ) { if( argv[ 1 ] == "-i" ) //This is what does not work //Do Something } But if I write the code like so this will work. int main( int argc, char *argv[] ) { string opti = "-i"; if( ...

C++ Books About Custom GUIs (winapi)

I'm looking for some books that will teach me how to create a custom GUI interface using the winapi. What I want to create is something that looks like this http://img199.imageshack.us/img199/2601/image1eal.png I don't want to use any libraries like GTK or QT, I want to do it from scratch so I can learn. I've looked everywhere on googl...

Recursion in Linked List

I want to print the reverse of a linked list. I am doing it by recursion. But while calling read(temp) in function read, it gives a BUS ERROR. Any reasons why is this happening ?? #include <iostream> using namespace std; struct node { int info; node *next; }; void read(node *start) { node *temp = start->next; if(sta...

Java JNI - associating resources allocated in C with java objects?

I want to allocate some memory in C and keep it associated with a java object instance, like this: void configure(JNIEnv *object, jobject obj, ....) { char *buf = new char[1024]; // associated <buf> with <obj> somehow } And then later free the memory when the java object gets garbage collected - I could do this by calling a JNI fu...

Defining global array

I have the following static array in header file: static MyStruct_t MyStructArray[] = { ...... ...... ...... } But gcc issues a warning: warning: `MyStructArray' defined but not used What is the correct way to handle the situation? UPD: Defining the array as const: const MyStruct_t MyStructArray[] = { .........

Basic C++ memory question

Hi, a friend of mine declared a new type using typedef GLfloat vec3_t[3]; and later used vec3_t to allocate memory vertices=new vec3_t[num_xyz* num_frames]; He freed the memory using delete [] vertices; Question: 1. Since vec3_t is an alias for GLfloat[3], does it mean that vec3_t[num_xyz* num_frames] is equivalent to GL...

How to check if process is still running on Windows server 2008?

We have two services: one service is 32-bit (process1) and the other is 64-bit (process2). We have code that process1 is using to check if process2 is running: HANDLE hProcess; RESET_WIN_ERRNO; hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ProcessId); if (hProcess == NULL) { os_SetWinErr(err_code); return FALS...