c++

how do i save time to a file?

hi, i have a program that saves data to file and i want to put a time stamp of the current date/time on that log but when i try to write the time to the file it will not show up but the other data i write will. #include <iostream> #include <windows.h> #include <fstream> #include <string> #include <sstream> #include <direct.h> #include <...

operator overloading(friend and member function)

Hi, Could anybody tell me the difference between operator overloading using the friend keyword and as a member function inside a class? also what is the difference incase of any unary operator overloading i.e., as a friend and as a member function ...

Convert __declspec to _export C++

Hi, I am converting the following function. But the new converted function is not executed. Any ideas? Old Function extern "C" DWORD __declspec(dllexport) FAR MyFunc (char *value1, int *value2) New Function extern "C" DWORD _export FAR MyFunc (char *value1, int *value2) ...

How do you scale a CBitmap object?

I've loaded a CBitmap object from a resource ID, and I'm now wanting to scale it to 50% its size in each dimension. How might I go about this? ...

Setting the pixel format of an existing Bitmap in GDI+

How do I set the PixelFormat property in a GDI+ Bitmap if I can't use one of the constructors that allow me to specify it? It looks like the PixelFormat property itself is read-only. ...

Why is there a sizeof... operator in C++0x?

I saw that @GMan implemented a version of sizeof... for variadic templates which (as far as I can tell) is equivalent to the built in sizeof.... Doesn't this go against the second design principle: prefer libraries to language extensions? ...

C99 strict aliasing rules in C++ (GCC)

As far as I understand, GCC supports all of its C99 features in C++. But how is C99 strict aliasing handled in C++ code? I know that casting with C casts between unrelated types is not strict-aliasing-safe and may generate incorrect code, but what about C++? Since strict aliasing is not part of C++ standard (is that correct?), GCC must ...

How to kill a process from VC++

Am using VC++ compiler i want to know how to kill a process. is there any functions. i tried with TerminateProcess(); but i couldn't do... ...

QStringListModel sorting

How can sort QStringListModel? Thanks a lot. ...

semicolon in C++?

Here is the question Is "missing semicolon" error really required? why not treat it as a warning? Why I am asking this stupid question? When I compile this code int f = 1 int h=2; the compiler intelligently tells me that where I am missing it. but to me its like - "If you know it, just treat it as if its there and go ahead. (Later ...

Struct Array Initialization and String Literals

Is following array initialization correct? I guess it is, but i'm not really sure if i can use const char* or if i better should use std::string. Beside the first question, do the char pointers point to memory segments of same sizes? struct qinfo { const char* name; int nr; }; qinfo queues[] = { {"QALARM", 1}, {"QTESTLON...

how can i diagnose exception in window 7 release mode compilation with VC 2008

Hi i have strange problem , my application (exe) is working fine in debug mode in windows 7 but stop to work with exception when compiling in release mode . how can i debug the program to find what is causing the exception this is application with more then 300,000 lines of code .. ...

How to lock file in Windows?

How to lock file in Windows so that this file can be opened/read/wrote only by one process? I found out that file can be locked with CreateFile by giving 0 to dwShareMode flag. It works but only the returned handle can be used to work with file. But I want to be able to lock the file to other processes and at the same time to create mul...

Is this function thread-safe?

Hello all,I am learning multi-threading and for the sake of understanding I have wriiten a small function using multithreading...it works fine.But I just want to know if that thread is safe to use,did I followed the correct rule. void CThreadingEx4Dlg::OnBnClickedOk() { //in thread1 100 elements are copied to myShiftArray(which is a...

Why exactly is calling the destructor for the second time undefined behavior in C++?

As mentioned in this answer simply calling the destructor for the second time is already undefined behavior 12.4/14(3.8). For example: class Class { public: ~Class() {} }; // somewhere in code: { Class* object = new Class(); object->~Class(); delete object; // UB because at this point the destructor call is attempted ag...

Is undefined behavior worth it?

Many bad things happened and continue to happen (or not, who knows, anything can happen) due to undefined behavior. I understand that this was introduced to leave some wiggle-room for compilers to optimize, and maybe also to make C++ easier to port to different platforms and architectures. However the problems caused by undefined behavio...

Is there a (Linux) C++ IDE that can 'construct' a project from a makefile?

I am working on a legacy C app which uses makefiles. I am more comfortable (and more productive) working from within an IDE, so I am looking for an IDE that can import the makefile and create a project. Incidentally, these are hand written makefiles (not complicated ones like those generated by Autoconf). I am using Code::Blocks at the ...

Using ntop Win32 x86

I want to compile ntop under Win32. I download all files but at compile time many classes are missing? Where could I find all needed source files for ntop? ...

How to write a build script for a C++ project

I am developing a C++ application on Ubuntu. The application consists of several modules, each with its makefile. I want to have a customised command line build process that does the following: checks code out from a repository (for specified branch/tag) builds the app (release or debug as specified) logs any errors etc I am too laz...

Errors in c++ faq lite?

Hello, I'm reading questions and answers around here for a few days. I have seen the c++ faq lite at Parashift has been mentioned many times. Personally I have always considered it to be a good reference, not my favourite one but certainly useful. Here I have seen somebody advising it, but many others commenting against it instead. Someb...