c++

Creating your own HRESULT?

I already have a project that uses alot of COM, and HRESULTS. ANyways i was wondering if its possible to define your own HRESULT, AND be able to use the FormatMessage() for our own HRESULT? I dug around and cant find anything. Any ideas? EDIT Basically i want to define a set of my own HRESULT's instead of just returning E_FAIL. Or one...

Reference in lhs and rhs difference in C++

I am learning C++ and I found that when a reference is on the right hand side, there can be two cases. Suppose I have a method: int& GetMe(int& i) { return i; } And I have: (1) int j; GetMe(j) = GetMe(i); and (2) int& k = GetMe(i); The consequences of (1) and (2) are different. In (1), the semantic is to copy the value of i into j....

Store an int in a char array?

Hey SO, This should be easy for all you C hackers out there :D Anyways, I want to store a 4-byte int in a char array... such that the first 4 locations of the char array are the 4 bytes of the int. Then, I want to pull the int back out of the array... Also, bonus points if someone can give me code for doing this in a loop... IE writi...

Boost equivalent of memcpy?

Hey all, Is there a boost equivalent for memcpy? Thanks! EDIT: Sorry, I didn't realize memcpy was in the standard library :) I thought it was an OS call :( ...

What is the proper method of reading and parsing data files in C++?

What is an efficient, proper way of reading in a data file with mixed characters? For example, I have a data file that contains a mixture of data loaded from other files, 32-bit integers, characters and strings. Currently, I am using an fstream object, but it gets stopped once it hits an int32 or the end of a string. if i add random d...

C++ strcmp array

Hi I am using strcmp as shown below. I am debugging the values and which are coming same but still not getting that condition true. const char opcode_read[2] = {'0', '1'}; rc = recvfrom(s, blk_receive_full, sizeof (blk_receive_full), 0,(struct sockaddr FAR *)&sin, &fromlength); if(rc == -1){ printf("failed: recvfrom, \n No data rec...

Sharing code between projects without svn:externals

In order to simplify the build process, I've been trying to reorganize my version control repository. I am developing a simple client-server application. Following Rob Williams' advice, I have separated the client and the server into separate projects each with their own lifecycle. The problem though, is that client and server share som...

Permutations of letters and numbers in a phone number.

For my computer science class, we need to write a program (in C++) that takes an input of characters and outputs the possible permutations of it according to the dial pad on a phone, leaving non-digit characters in place. For example, inputing 2 outputs 2, A, B, C. Inputing 23 outputs 23, A3, B3, C3, 2D, 2E, 2F, AD, AE, AF, BD, BE, BF, ...

Does GCC support long long int?

Title basically says it all... does GCC support: long long int which would be a 64 bit integer? Also, is long long int part of the standard? Thanks ...

Determine which application is preventing shutdown

Unlike Windows Vista, when Windows XP is shutting down - it doesn't tell you which program is requesting not to be shutdown. This leaves Windows still running and not telling you what program is preventing shutdown. As I understand it, Windows sends WM_QUERYENDSESSION to all applications. If any of the applications return 0 to the funct...

Where hardcoded values are stored ?

Hi For an investigation i need to know where hard-coded values are stored. Question : A function having hard-coded values inside it , and this function is called by many threads at same time , is there any chance that that hard-coded value will be corrupted. For example : myFunc is called by many thread at same time . c...

How to place 90X90 icon

Hi, i am creating .cab file installer for windows mobile application, problem is i need to keep the 90X90 .png image as icon for application. as per the link i tried to load the icon,step am following are 1) writing the icon path to registry 2) then loading the icon... i followed the step mentioned above link, but the problem is i...

Advice needed: stay with Java team or move to C++ team?

Some background - I have been programming in Java as a professional for the last few years. This is mainly using Java SE. I have also touched bits and pieces of other various Java technologies and have some basic knowledge about them. I consider my self as an intermediate Java programmer. I like Java very much. I think it is only go...

Win32Api - Window Name Property

Is there any way to get a control's name through win32api? (c++) I'm talking about the property that in C# is 'Name', like 'frmMain', or 'btnNext'. Is there any way to retrieve this data through the win32API? I've tried GetWindowInfo() and stuff but I think I'm not heading in the right direction.. thanks edit: I'm iterating with Enu...

Is there any C++ codes available to view XPS document?

Is there any C/C++ codes available to view XPS document EDIT Is there any C++ codes available to Edit (add watermark) in XPS document ...

which namespace does toupper belong to

Hi Guys, when I'm reading some c++ sample code for beginner , I'm puzzled at the usage of toupper in the following line : std::transform(data.begin(), data.end(), data.begin(), ::toupper); from the above line, I know that "transform" is from namespace std , but I don't know which namespace does toupper come from . maybe there is a de...

How to handle same socket in different threads?

I am trying to handle socket in different threads creating runtime failure. See following code. void MySocket::Lock() { m_LockCount++; if( m_LockCount ) { CSocket::Create( 8080 ); } } void MySocket::Unlock() { m_LockCount--; if( !m_LockCount ) { CSocket::Close(); } } I am calling Lock() fro...

API for Giving Notification when a file is added or deleted in a folder

is there any windows API or shell API which will give a notification on when a file is added or deleted in a folder ...

ANSI C functions namespace in ISO C++

Consider the following small program: #include <cstdio> int main() { printf("%d\n", 1); std::printf("%d\n", 2); return 0; } What does C++ standard say about importing C library functions into global namespace by default? Can you point me to the relevant C++ standard section? What is the reason ANSI C functions are in std...

Algorithms and Data Structures best suited for a spell checker, dictionary and a thesaurus

Best way to implement a dictionary (is their any DS better than Trie for Dictionary) thesaurus (no idea, as match is made on meanings of the words, similar meanings) spell checker (something better than a hash map), if possible with correct spelling recommendations. when asked in an 1-hr interviews, are we expected to write a...