I'm trying to build a 32bit float out of its 4 composite bytes. Is there a better (or more portable) way to do this than with the following method?
#include <iostream>
typedef unsigned char uchar;
float bytesToFloat(uchar b0, uchar b1, uchar b2, uchar b3)
{
float output;
*((uchar*)(&output) + 3) = b0;
*((uchar*)(&output) ...
I am writing some video files under Windows from a camera.
I need the data unaltered - not MP4's 'uncompressed' ie. no YUV, no color interpolation - just the raw camera sensor bytestream.
At the moment I am writing this direct to disk and re-reading it later to recode into a usable video. But with no header I have to keep track of image...
Hi
I’ve problem with this function using winsock2. When program leave this function in debug mode I receive 2 statements (only during exiting this function):
“Run-Time Check Failure #2 - Stack around the variable 'filePath' was corrupted.”
“Run-Time Check Failure #2 - Stack around the variable 'recBuf' was corrupted.”
I’m programming...
Is there a function that returns how much space is free on a drive partition given a directory path?
...
A while ago I asked about std::string constants http://stackoverflow.com/questions/2312860/correct-idiom-for-stdstring-constants.
What I took away from that was not to use std::string constants but to use char string constants. So what the best idiom for that
#define FOO "foo"
const char * const FOO = "foo";
const char FOO[] = "foo";...
I'm creating a stat editor for some objects within a game world. Rather than have multiple edit menus for each object type, I just have one menu, and pass in a list/vector of stat-edit-objects which contain a pointer to the stat being edited, and the functions to do the work.
struct StatEditObjPureBase
{
std::vector<std::string> rep...
So... I will have a project which will be tested on Win 7 and some Linux server. It will be a web service that will use HSQLDB, Hibernate, Spring, Blaze DS and Flash (Flex RIA) as front end. I need to implement into it some image filtering\editing functionality which will be implemented in cross-platform C++ code (It will use Open-CV) w...
how do you make ctags account for class in c++? when i jump to a tag of a function i get to the same name of the function but in a wrong class.
B b;
b.init();
and there are
A::init() {}
B::init() {}
i put the cursor on init of b.init() and the jump is to A::init() {} instead of B::init() {}.
Note, i didn't use a and b in my code. so...
The struct looks like this:
template <class Node_entry>
Node<Node_entry>::Node(Node_entry item, Node *add_on)
{
entry = item;
next = add_on;
}
And the *new_rear pointer does not get initialized, but &item is filled with user input.
Error_code Extended_queue::append(const Queue_entry &item) {
Node<Queue_entry> *new_...
This is a follow up question to Char* vs String Speed in C++.
I have declared the following variables:
std::vector<std::string> siteNames_;
std::vector<unsigned int> ids_;
std::vector<std::string> names_;
I call this function tens of thousands of times and is a major bottleneck. Is there a more efficient way to compare strings? The a...
Why does the code sample below cause one thread to execute way more than another but a mutex does not?
#include <windows.h>
#include <conio.h>
#include <process.h>
#include <iostream>
using namespace std;
typedef struct _THREAD_INFO_ {
COORD coord; // a structure containing x and y coordinates
INT threadNumber; // eac...
Hi,
Is there a function that returns the fully qualified path name for any inputted file?
I'm thinking of something like:
LPCSTR path = "foo.bar"
LPCSTR fullPath = FullyQualifiedPath(path);
//fullPath now equals C:\path\to\foo.bar
Thanks
...
I would like to clear the command line of my process from within. For example, when viewing my process in Task Manager/Process Explorer, the command line entry would be empty.
I would like to do this within the currently running process rather than restarting the process if possible.
...
Basically, what I need is a way to tap into the current audio output and check the sound level, i.e. I need to be able to check whether there is something playing on the audio device or not.
I do not need to check the volume setting, but the actual playing audio stream's sound level.
Sorry, I was asking about how to do it in Windows, o...
I have a base class A and classes B and C are derived from it. A is an abstract class, and all three classes have a constructor that takes 2 arguments. Is it possible to make a method in the base class A like this:
A* clone() const
{
return new this.GetType(value1, value2);
}
and if the current object whose clone()-function is bei...
I know that inline member functions by definition should go into the header. But what if it's not possible to put the implementation of the function into the header? Let's take this situation:
File A.h
#pragma once
#include "B.h"
class A{
B b;
};
File B.h
#pragma once
class A; //forward declaration
class B{
inline A getA(...
Hi everyone. This might be a stupid question to a experience programmer... but anyway, I just want to figure out. What's the difference between if("Hello"==$helloString) and if(helloString=="Hello")? I thought the order in a if statement doesn't matter but I guess there must be something wrong with my thought. So could someone expalin it...
My assignment is a Binary Search Tree derived from a Binary Tree, in my driver program this is how I've created a BST object. But I am slightly confused because I know there must be a constructor but no where in my assignment does it actually call for a constructor for the derived class.
int main() {
int x = 0;
int n = 0;
int l...
I am trying to use static fields in QT
class MyLabel:public QLabel{
Q_OBJECT
public:
static QPixmap pix1;
static QPixmap *pix2;
static int WasInited;
...
};
int MyLabel::WasInited = 0;
MyLabel::MyLabel(){
. . .
if (WasInited==0) pix1.load("pic.png"); // Error
if (WasInited==0) pix2->load("pic.png"); // Error
...
I keep getting the first entry appended 4 times instead of one time.. when I append my first entry to the Queue it appends it 4 times..I thought this might be the problem..but it looks like it isn't. I can't find where the problem is..
I also created a print function for the nodes, and it showes that there are 4 of the same entries in t...