I am porting from Linux to FreeBSD and have run into ::mknod() failing with errno:
[EINVAL] Creating anything else than a block or character spe-
cial file (or a whiteout) is not supported.
But I also see it states earlier on the man page:
The mknod() system call requires super-user privileges.
So what...
I want this code to represent symbols and not numbers (A, O, X)?
Can someone give me a simple code to make the numbers into symbols? Thanks
int game[3][3];
int x, y;
int lines = 0;
// select a random grid
srand(time(0));
for(x = 0; x < 3; x++) {
for(y = 0; y < 3; y++) {
game[x][y] = rand() % 3;
cout << game[x][y];
if (y ==...
I'm a completely new to C++ and I'm having a very stupid problem.
I have a Graph class and I need to create a copy constructor for it. This is my class:
#include <igraph.h>
#include <iostream>
using namespace std;
class Graph {
public:
Graph(int N); // contructor
~Graph(); // destructor
Graph(const Graph& other); // Copy ...
I tried getline(cin, .... ), but this cannot take input more than one line. The end of input is determined by something like #.
...
Hello,
Basic c++ question here. I'm trying to read a large file on Windows 7 Pro. C++ compiler is Visual Studio 2010. (ver 16.0). I'm finding that the program runs about 5 times slower on Windows 7 than one on a virtual machine running Ubuntu on the same box. Ubuntu version 10.04 using gcc 4.4.3. The file is rather large ~900MB. The cod...
Hi assume that I have class A :
using namespace std;
template <class T>
class A{
private:
vector<T> my_V;
public:
// assume initializations etc are done
inline vector<T> get_v()
{
return my_v;
}
};
and some where else I have overloaded ostream of std::vector
template <class T>
ostream & operator<<(ostream& out, vector<T> &vec...
So I've got:
class bc_Game
{
public:
//blah
private:
b2World world;
};
bc_Game::bc_Game()
{
//blah, defining variables used
world = b2World(gravity, sleep);
}
Now, I just get
error: no matching function for call to 'b2World::b2World()'
note: candidates are: b2World::b2World(const b2Vec2&, bool)
note: b2World::b2Worl...
Here is what my algorithm does:
It takes a long std::string and divides it into words and sub words based on if it's greater than a width:
inline void extractWords(std::vector<std::string> &words, std::string &text,const AguiFont &font, int maxWidth)
{
words.clear();
int searchStart = 0;
int curSearchPos = 0;
char rig...
Using Ubuntu 10.10 I have compiled and installed the latest Ogre and CEGUI libraries.
I can #include for example but when I try to add the CEGUI headers I have issues.
#include <CEGUI/RendererModules/Ogre/CEGUIOgreRenderer.h>
This in turn includes OgreBlendMode.h and OgreTextureUnitState.h but doesn't have the OGRE/ in front of it.
...
this is my struct :
struct Node {
struct Node* data;
struct Node* links[4];
}
assuming there is no padding, does Node->links[-1] guaranteed to be pointing on Node::data ?
...
Hello, I'm trying to connect a very basic twisted "hello world" server with a basic Qt tcp client.
The client uses these Signals:
connect(&socket, SIGNAL(connected()), this, SLOT(startTransfer()));
connect(&socket, SIGNAL(readyRead()), this, SLOT(readServer()));
and then readServer() looks like this:
ui->resultLabel->setText("Readin...
Hi!
usually, if my #include chain gets circular, I solve it by replacing one of the #includes by a forward declaration and then move all the function implementations that depend on this type into the cpp file, where I #include the header instead.
But - in some situations it's bad to put function implementation into the cpp file - espec...
I'm trying to build a Tetris AI algorithm that can scale over multiple cores.
In my tests it turns out that using multiple threads is slower than using a single thread.
After some research I found that my threads spend most of their time waiting for _Lockit _Lock(_LOCK_DEBUG). Here's a screenshot.
As you can see, the lock is applied o...
This is my makefile:
delay:
tc qdisc add dev eth0 root netem delay 0ms
test4_s_delay:delay
./a.out 10 10 1 2 3 1 1 20 | tee server_delay.txt
but,I am getting the following error on executing the makefile:
root@superwii-laptop:/home/superwii/Desktop/Amogh# make test4_s_delay
tc qdisc add dev eth0 root netem delay 0ms
RTNETLINK...
I'm trying to get the maximum size of any possible instance of my template as a compile time constant. The first thing that came to mind was something like this...
union TestUnion
{
template<typename T> class MyClass
{
public:
MyClass() { };
MyClass(T& t) : _t(t) { }
private:
T _t;
};
};
But sizeof(TestUnion) is always equ...
Is it bad form to use the GNU getopt in C++ programs? Is there a C++ specific alternative, or should I still just use getopt?
...
Hi,
I have a DllMain defined as so:
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
int i=0, DoHijack=0;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
hMod = hModule;
hProcessCenter = ::FindWindow(NULL, _T("Form1"));
...
I'm trying to apply the technique described in http://www.drdobbs.com/tools/227500449
With the sample code below, I expect the output:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
And this is indeed what happens if I compile using clang. But with gcc, this code gives the following errors:
junk.cpp: In instantiation of ‘const bool has_fo...
I want to learn how to read other processes memory and have my program call the other processes functions and what not with my own parameters and stuff. I've googled it and it seems like you need to use things like ReadProcessMemory but I haven't been able to find any good tutorials explaining how to use them. Could anyone point me in th...
Hi i want to overwrite the content(object) in a specific file i have set the position but it always add to the end of the file
Code
int InputIO::editPatient(int location,Obj P){
int positon=location*sizeof(P);
f.open("File.dat",ios::in|ios::out|ios::app|ios::binary|ios::ate);
f.seekp(0,ios::beg);
f.see...