c++

How to append text to a text file in C++?

How to append text to a text file in C++? Create new if does not exist and append if exist. ...

HTML to XML conversion with C++

Is there a C++ code or library to convert a HTML document to a XML document? Thanks. ...

Can I overload operators on enum types in C++?

For example, if I have: typedef enum { year, month, day } field_type; inline foo operator *(field_type t,int x) { return foo(f,x); } inline foo operator -(field_type t) { return t*-1; } int operator /(distance const &d,field_type v) { return d.in(v); } Because if I do not define such operators it is actually legal to write da...

Why does using the same count variable name in nested FOR loops work?

Why does the following not give an error? for (int i=0; i<10; ++i) // outer loop { for (int i=0; i<10;++i) // inner loop { //...do something } //...do something else } The way I understand it, variables in braces ({...}) are in scope only within these braces. But the inner loop is inside the braces of the outer loop. S...

undefined C/C++ symbol as operator

I notice that the character/symbol '`' and '@' is not used as an operator in C/C++, does anyone know the reason or historically why its so? if its really not used, is it safe to define those symbols as another operator/statement using #define? ...

Project suggestions needed for "interview preparation demo program"

I have a job interview next week that requires me to be able to demonstrate the following skills: C C++ SystemC 3D Video Digital communication RTL (register transfer level) Usually before an interview, I create a quick application just to refresh my knowledge of all the skills required, but I can't think how to combine all of these i...

Python code to parse and inspect c++

Is there a library for Python that will allow me to parse c++ code? For example, let's say I want to parse some c++ code and find the names of all classes and their member functions/variables. I can think of a few ways to hack it together using regular expressions, but if there is an existing library it would be more helpful. ...

Visual studio compiler flag /arch and performance

I just noticed that in our project have left the "Enable Enhanced Instruction Set" flag left unset, probably just an oversight. Before enabling the flag I would like to ask if anyone have seen any real-world performance improvements enabling it ? I guess we will see some improvement our application constantly do floating point based c...

C++ and,or,not,xor keywords

Possible Duplicate: The written versions of the logical operators. I notice that C++ define keyword and, or, not, xor, and_eq, or_eq, not_eq and xor_eq as an alternative to &&, ||, !, ^, &=, |=, != and |=. and they're rarely used! What's wrong? Are they not portable? ...

C++: Why isn't operator placement new recognized as an inline friend function in a (template) class in VS2005?

I've inherited a Visual Studio 6.0 project to convert to 2005. It includes this fantastic MyClass class below that client code uses everywhere by invoking placement new on an instance of it (greatly simplified here): #include <new> #include <cstdio> template<class T> class MyClass { public: // This is what the author assumed would...

Set an exe icon for my program

Hello! I'm using Microsoft Visual Studio 2008 and I'm trying to set an exe icon for my program. I've searched this site and found this: htp://stackoverflow.com/questions/320677/how-do-i-set-the-icon-for-my-application-in-visual-studio-2008 But I cant find this "Resource View". Looked everywhere in MVS08 Please help! http://i46.tinyp...

how do i add a int to a string.

i have a string and i need to add a number to it i.e a int. like: string number1 = ("dfg"); int number2 = 123; number1 += number2; this is my code: name = root_enter; // pull name from another string. size_t sz; sz = name.size(); //find the size of the string. name.resize (sz + 5, account); // add the accoun...

Removing the repeating pattern in C++

Hi, I have atleast 16 functions of the following form. bool Node::some_walker( Arg* arg1 ) { if(this == NULL) return false; bool shouldReturn = false; if( this->some_walker_p(arg1, shouldReturn) ) //This line alone varies return true; if( shouldReturn ) // true is already returned return fal...

Possible to create a dual-seekable Boost Iostream using a file_descriptor?

I'm trying to update a random-access binary file using the std::iostream interface with separate get/put positions managed via seekg/seekp. Everything works fine with stringstream, but when I create a file descriptor-based stream using Boost.Iostream (specifically boost::iostreams::stream<boost::iostreams::file_descriptor>), the get/put ...

Remove comments from C/C++ code

Is there an easy way to remove comments from a C/C++ source file without doing any preprocessing. (ie, I think you can use gcc -E but this will expand macros.) I just want the source code with comments stripped, nothing else should be changed. EDIT: Preference towards an existing tool. I don't want to have to write this myself with reg...

STL set not adding properly c++

I am adding musicCD information to a set. I have two different functions for this. The problem is adding the musicians. Its only adding the last musician being passed in like its copying over the first ones. here is the required output to give you an idea of the info. Only ringo starr is adding and not "George Harrison" "John Lennon". ...

Calling C# From Unmanaged C++ Passing Or Returning "Complex" Types

Hello, I'm after help on how to use complex objects either as return values or passed as parameters to C# class methods exposed to unmanaged C++ as COM components Here's why: I'm working on a project where we have half a dozen unmanaged C++ applications that each directly access the same Microsoft SQL Server database. We want to be ab...

Graph colouring algorithm: typical scheduling problem

Hi, I'm training code problems like UvA and I have this one in which I have to, given a set of n exams and k students enrolled in the exams, find whether it is possible to schedule all exams in two time slots. Input Several test cases. Each one starts with a line containing 1 < n < 200 of different examinations to be scheduled. The 2nd...

Searching std::string between a limit

if you know the start and end positions in string from where to begin and end the search. For example - string s = StringStringString |S |t |r |i |n |g |S |t |r |i |n |g |S |t |r |i |n |g 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 How would you find "tr" in the string specifying the the position to begin search is at inde...

GLSL Error: 2001 - What does this error code mean?

I got this after querying the info logs when a compile error occurred. I have not been able to find a single resource that tells me what the error code even means! Using Ubuntu 9.10 with an Intel mobile chipset that supports glsl 1.1. Mesa driver. Vertex Shader: #version 110 in vec3 m2d_blendcolor; out vec3 color; // out vec2 texcoor...