i gt a struct with 2 integer, i want to store them in a binary file and read it again...
here is my code...
static const char *ADMIN_FILE = "admin.bin";
struct pw {
int a;
int b; };
void main(){
pw* p = new pw();
pw* q = new pw();
std::ofstream fout(ADMIN_FILE, ios_base::out | ios_base::binary | ios_base::trunc);
std::ifst...
I'm a bit confused what happened in the following code:
const int e = 2;
int* w = ( int* ) // (1) cast to remove const-ness
*w = 5; // (2)
cout // (3) outputs 5
cout // (4) outputs 2
cout // (5) w points to the address of e
cout
In (1), w points to the address of e. In...
During debug mode or while I am doing testing, I need to print lots of various information, so i use this method:
#ifdef TESTING
// code with lots of debugging info
#else
// clean code only
#endif // TESTING`
Is this a good method, or is there any other simple and elegant method ?
But this way, I am repeating the same code in two pla...
How print format string passed as argument ?
example.cpp:
#include <iostream>
int main(int ac, char* av[])
{
printf(av[1],"anything");
return 0;
}
try:
example.exe "print this\non newline"
output is:
print this\non newline
instead I want:
print this
on newline
...
Hello,
I am trying to create a static library of my own. I am however using a third party static lib as well. Now, in my static library I have a .h file which has the client's API in it. All the implementation details are in the .cpp file. No issues there. But, some of my functions in the .cpp file rely on this third party lib.
I can...
I've been using matplotlib in a Python project. It is great.
I have now to plot data in a C++ project. Is anyone aware of a plotting library in C or C++?
Note that I cannot accept GPL licensed libraries.
...
Hello there,
I got this error
Unhandled exception at 0x0049b946 in Program.exe: 0xC0000005: Access violation reading location 0x00000090.
and the error points to this line:
// thread.hpp ln 56
void run()
{
f(); // here <<
}
When trying to run this code:
void frameFunc()
{
for(;;)
...
I am trying to write a container class which uses STL allocators. What I currently do is to have a private member
std::allocator<T> alloc_;
(this will later be templated so that the user can pick a different allocator) and then call
T* ptr = alloc_.allocate(1,0);
to get a pointer to a newly allocated 'T' object (and used alloc_.con...
To name a few:
`__debugbreak' was not declared in this scope sphinx.cpp /sp/src line 146 C/C++ Problem
`__rdtsc' was not declared in this scope sphinx.cpp /sp/src line 452 C/C++ Problem
`__stat64' does not name a type sphinx.cpp /sp/src line 15963 C/C++ Problem
Are you familiar with the error info?Is there something I...
#include <iostream>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
If I remove the 2nd statement,the build will fail.
Why is it necessary?
...
I'm looking for a nice stackoverflow-style answer to the first question in this old blog post, which I'll repeat below:
"I’d really like some tool (ideally, g++ based) that shows me what parts of compiled/linked code are generated from what parts of C++ source code. For instance, to see whether a particular template is being instantiate...
To access the array indice at the xth position we can use some sort of illustration as shown below
#include<iostream>
using namespace std;
int main(){
float i[20];
for(int j=0;j<=20;j++)
i[j]=0;
}
However the following piece of code does not work
#include<iostream>
using namespace std;
float oldrand[55];
int jrand;
...
I have a singleton library from a linux project that I'm trying to port to Windows. When I try to compile, it errors with
syntax error: identifier "rpSingleton"
The error is from the following section of code:
template <typename T> inline T&
Q::Singleton<T>::Instance()
{
Singleton<T>*& rp_singleton(rpSingleton()); //ERRORS...
Hi,
I want to compile only the thread and regular expresession library of boost and I want both static and dynamic libs. Could you please let us know how to do that?
Thanks.
...
We have a program which launches a child process that hosts a local COM server, which for various reasons must be launched elevated. Everything works fine so long as both the parent and the child process are elevated.
However, we also want to run when the parent process is non-elevated. Launching the child process results in a UAC dialo...
hello, i'm new at C Programming (i learned c++) i want to create a process with windows.h
at first i just want to start my main programm that creates a process ( --> starts an other programm)
that's my code, but it doesn't really work, i removed every unnessasery line of code but "void sleep(700)" (or "sleep (700)" for testing if the w...
I know this is probably a silly question.. When would I need to write my own iterator? Is it just when designing my own container class? Are there any other times when I would want to create my own iterator?
Examples would be appropriated.
-Jon
...
I need to monitor a directory which contains many files and a process reads and deletes the .txt files from the directory; once all the .txt files are consumed, the consuming process needs to be killed. How do I check if all the .txt files are consumed using C++?
I am developing my application on Visual Studio on windows platform.
...
Hi I am am trying to catch mouse movements for a MouseOver function in an app created with Code::Blocks using the wxSmith plugin. I have stumbled upon a puzzling problem. EVT_MOUSEWHEEL calling the function in the EventTable works well, but all other macros have no result at all. And the mousewheel is not really want I want (I just ...
The following C++ program crashes on my Windows XP machine with a message "Abnormal program termination"
class Thing {};
int main()
{
for (;;) new Thing();
}
I would say it's an out of memory problem, except I'm not sure Windows gets near the limit. Is it Windows killing it on purpose? If so, how does it decide?
...