c++

How to catch Ctrl+C key event with Qt when Ctrl is released before 'C'?

I would like to call some custom copy code when the user releases Ctrl+C. When 'C' is released before Ctrl, Qt sends a key event that matches with QKeySequence::Copy. When Ctrl is released before 'C', the release event does not match. When the key release event comes in with Ctrl, is there a way to see if 'C' is still being held down? ...

Segfault when calling Gtkmm textBuffer->insert

I'm just learning about gtkmm for c++. I'm having trouble getting a simple TextBuffer to add a new line of text. I have a class called OutputBox which is an HBox with a TextViewer (called messages) and a TextBuffer (called textBuffer) in it. Here is a small chunck of the OutputBox class: OutputBox::OutputBox() { textBuffer = messages...

How can I easily use a COM component in Native Visual C++

Hi there. I am trying to build an app that uses a COM component in VisualStudio ´05 in native C++. The mix of native and managed desciptions of things in the MSDN totally wrecked my brain. (I think the MSDN is a total mess in that respect) I need a short and simple native C++ sample of code to load my Component and make it usable. I am ...

get list of numbers from stdin and tokenize them

How would I get a list of numbers from the user and then tokenize them. This is what I have but it doesn't get anything except for the first number: #include <iostream> #include <sstream> #include <vector> #include <string> using namespace std; int main() { string line = ""; cin >> line; stringstream lineStream(line); ...

find() problems

Hello, all! I've got an error while using find() function. Here is the code: #include <iostream> #include <map> #define N 100000 using namespace std; int main (int argc, char * const argv[]) { map<int,int> m; for (int i=0; i<N; i++) m[i]=i; find(m.begin(), m.end(), 5); return 0; } I'm getting an compiller error...

How to override Py_GetPrefix(), Py_GetPath()?

I'm trying to embed the Python interpreter and need to customize the way the Python standard library is loaded. Our library will be loaded from the same directory as the executable, not from prefix/lib/. We have been successful in making this work by manually modifying sys.path after calling Py_Initialize(), however, this generates a wa...

Omitting arguments in C++ Templates

When calling a template function, is it ok to omit the type after the function name? As an example, consider the function template<typename T> void f(T var){...}; Is it ok to simply call it like this: int x = 5; f(x); or do I have to include the type? int x = 5; f<int>(x); ...

getc(stdin) reads keyboard input to integers, but what if I want to read keyboard input to character strings? (C++) Thanks

#include "stdafx.h" #include "string.h" #include "stdio.h" void CharReadWrite(FILE *fin); FILE *fptr2; int _tmain(int argc, _TCHAR* argv[]) { char alpha= getc(stdin); char filename=alpha; if (fopen_s( &fptr2, filename, "r" ) != 0 ) printf( "File stream %s was not opened\n", filename ); else printf( "The fi...

Is it OK to use a macro to specialize std::swap?

So, I have a macro. // swap_specialize.hpp #include <algorithm> #ifndef STD_SWAP_SPECIALIZE #define STD_SWAP_SPECIALIZE( CLASSNAME ) \ namespace std { \ template<> inline \ void swap( CLASSNAME & lhs, CLASSNAME & rhs ) \ { lhs.swap(rhs); } } #endif So then I have a class // c.hpp #include...

C++ Functors and Zero

Hello all: First a disclaimer, I am replacing a bunch of code which uses boost::function and boost::bind. However, I am moving to a codebase which does not allow rtti. I would like to keep using boost but don't know if there is a way around this restriction. So..., I am trying to mimic some of its functionality, but much more simplif...

Comparing values input to values in a vector

I'm trying to input a form of data validation in which when a user enter's a book's ISBN number, if it has already been stored then it will output an error message. However, I'm having trouble doing this. I'm not sure if I'm overloading the == operator correctly, and I'm not sure how to compare the vector values in the store_ISBN() funct...

error LNK2005: new and delete already defined in LIBCMTD.lib(new.obj)

Hi All, I have a Visual studio 2005 solution that has two projects. One is a static library and the other is a executable used to test the features in the static library. The static library uses MFC. I got the following errors when I built the solution. uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int...

Log user ip addresses when user fire prints command using print server

I have confusion over logging users' IP addresses when they fire print commands using the print server... My confusion starts: How should I know whether printing command is fired. My open question is like: What is print server How print server work in Window... How muliple client will send request to single print server Is any utility i...

How do I code a progress bar for Windows 7 to also update itself on the taskbar?

Windows 7 has an AWESOME new feature that applications can report the progress of the current activity through the status bar. For example, when copying file(s) using Windows Explorer, a progress bar is layered on top of the application icon in the task bar and the progress is shown as it updates. What is the API for exposing the progr...

How to check whether the tlb file is registered in registry using C++?

Hi I have created a class library using c#.And i have registered the class library using regasm.. RegAsm.exe Discovery.dll /tlb: Discovery.dll /codebase Now i want to know whether the assembly is registered or not using c++. I need because I have to check the registry for this dll if it is not registered I have to registered it ...

C++ Compiling first time

I will you show my misinterpretation. it says there must be del *.obj in the bat file it says there must be an obj file it says the obj file must actually be a cpp file Please, show me your interpretation. http://computerprogramming.suite101.com/article.cfm/the_borland_win32_compiler_guide Thanks! ...

Connecting Catmull-Rom splines together and calculating its length?

I'm trying to create a class which takes in any number of points (position and control) and creates a catmull-rom spline based on the information given. What I'm doing - and I'm really unsure if this is the right way to do it - is storing each individual point in a class like so: class Point { public: Vector3 position; Vector3 control...

Borland Can't Compile, what is going on, I can't even get started

C:\BORLAND\BCC55\BIN>bcc32 hello.cpp Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland hello.cpp: Error E2209 hello.cpp 2: Unable to open include file 'iostream' Error E2090 hello.cpp 6: Qualifier 'std' is not a class or namespace name in fun ction main() Error E2379 hello.cpp 6: Statement missing ; in function main() *** 3 er...

Is there a tool that enables me to insert one line of code into all functions and methods in a C++-source file?

It should turn this int Yada (int yada) { return yada; } into this int Yada (int yada) { SOME_HEIDEGGER_QUOTE; return yada; } but for all (or at least a big bunch of) syntactically legal C/C++ - function and method constructs. Maybe you've heard of some Perl library that will allow me to perform these kinds of operations...

Designing a C++ library

I am in the process of designing a C++ static library. I want to make the classes generic/configuarable so that they can support a number of data types(and I don't want to write any data type specific code in my library). So I have templatized the classes. But since the C++ "export" template feature is not supported by the compiler I a...