Hello!
I am taking a course on programming, and we're using C++.
We had an assignment where, at some point, we needed to code a function that would return a random number in an [upper, lower] interval. I used the following:
lower + (int) (upper * (rand() / (RAND_MAX + 1.0)));
I did not forget to change srand by using srand((unsigned ...
So all I need is a simple function that sets it up (eating incoming PCM RATE (for example: rate near to 44100) It's channels (for example: 2) and -bits (for example: 16) and desirable 128 kb\s rate) and another one that takes PCM data and encodes it into pure MP3 frames.
I know it looks like a silly homework task but I assure you - it i...
I am making a simple byte buffer that stores its data in a char array acquired with new and I was just wondering if the memcpy and memmove functions would give me anything weird if used on memory acquired with new or is there anything you would recommend doing instead?
...
I am currently using WM_DEVICECHANGE to be notified when new USB drives are connected to the computer. This works great for devices like thumb-drives where as soon as the device arrives it is ready to have files read from it. For devices like SD card readers it does not because the message is sent out once when the device is connected ...
So, I'm using the FMOD api and it really is a C api.
Not that that's bad or anything. Its just it doesn't interface well with C++ code.
For example, using
FMOD_Channel_SetCallback( channel, callbackFunc ) ;
It wants a C-style function for callbackFunc, but I want to pass it a member function of a class.
I ended up using the Win32...
I have written a simple C++ shell program to parse large XML files and fix syntax errors.
I have so far covered everything I can think of except strings within strings, for example.
<ROOT>
<NODE attribute="This is a "string within" a string" />
<ROOT>
My program loops through the entire xml file character by character(keeping only ...
I'm trying to use a delegate library in gcc http://www.codeproject.com/KB/cpp/ImpossiblyFastCppDelegate.aspx but the "preferred syntax" is not recognized by gcc 4.3. I.e. howto make compiler understand the
template < RET_TYPE (ARG1, ARG2) > syntax instead of template ??
TIA
/Rob
...
This is a stupid question. :)
[EDIT: stupid or not, this turned out to be a C++ peculiarity question, see UPDATE_2]
Suppose we have:
int a = 0; // line 1
int b = ++a; // line 2
What happens in line 2 is (note, numbers are just markers and do not specify exact order):
= [1: write result of (3) to result of (2)...
The MSDN site says:
From your view class's function that handles the WM_CREATE message (typically OnCreate), call the new member variable's Register member function. Revoke will be called automatically for you when your view is destroyed.
But I don't have an OnCreate function in the ChildView class.
I do have OnCreate in the CMain...
I have a grid of rectangular cells covering a plane sitting at some distance from the coordinate system origin and would like to identify the grid cell where a straight line starting at the origin would intersect it.
The cells on the grid have equal sizes (dx,dy) and there are no gaps between cells, but since every cell on the plane has...
Hi, I tried to read CPUID using assembler in C++. I know there is function for it in , but I want the asm way. So, after CPUID is executed, it should fill eax,ebx,ecx registers with ASCII coded string. But my problem is, since I can in asm adress only full, or half eax register, how to break that 32 bits into 4 bytes. I used this:
#inc...
I'm converting some code written for a linux system to a windows system. I'm using C++ for my windows system and wanted to know the equivalent of the function inet_aton.
...
I am using ACE threads and need each thread to have its own int member.
Is that possible?
...
Using MSXML4, I am creating and saving an xml file:
MSXML2::IXMLDOMDocument2Ptr m_pXmlDoc;
//add some elements with data
SaveToDisk(static_cast<std::string>(m_pXmlDoc->xml));
I now need to acquire a substring from m_pXmlDoc->xml and save it. For example, if the full xml is:
<data>
<child1>
<A>data</A>
<One>da...
Apologies if I missed this question already, but I searched and couldn't find it.
I have been out the C/C++ world for a little while and am back on a project. I was wondering what tools are preferred today to help with development.
The types of tools I'm referring to are:
Purify
Electric Fence
PC-Lint
cscope
Thanks!
...
Are static variables stored on the stack itself similar to globals? If so, how are they protected to allow for only local class access?
In a multi threaded context, is the fear that this memory can be directly accessed by other threads/ kernel? or why cant we use static/global in multi process/ thread enviornment?
...
In my program, fin is an ifstream object and song is a string.
When the program runs, it opens music.txt and reads from the file. I try to read each line with: getline(fin,song);
I've tried all variations of getline but it keep ignoring the first 10 or so characters of each line before it starts picking up characters. For instance, if ...
I have used sendinput() function and windows keyboard hooks to develop a custom keyboard for indian languages.
Project is in google code here: http://code.google.com/p/ekalappai
The keyboad hook and sendinput functions are placed in a win32 dll. And they are called from a Qt exe.
Our application works fine for most keys and application...
First time on StackOverflow, so please be tolerant.
In the following example (apologies for the length) I have tried to isolate some unexpected behaviour I've encountered when using nested classes within a class that privately inherits from another. I've often seen statements to the effect that there is nothing special about a nested cl...
Is there a way to make the GNU C Preprocessor, cpp (or some other tool) list all available macros and their values at a given point in a C file?
I'm looking for system-specific macros while porting a program that's already unix savvy and loading a sparse bunch of unix system files.
Just wondering if there's an easier way than going hun...