Suppose I define a union like this:
#include <stdio.h>
int main() {
union u {
int i;
float f;
};
union u tst;
tst.f = 23.45;
printf("%d\n", tst.i);
return 0;
}
Can somebody tell me what the memory where tst is stored will look like?
I am trying to understand the output 1102813594 that this p...
Suppose I do a
double d = 234.5;
I want to see the memory contents of d [the whole 8 bytes]
How do I do that?
...
i have a std::map and i am using iterator to find a certain key,value pair. After finding it i am unable to get the position of the key,value pair from the iterator. By doing another find i can get it, but i want a work around for this.
//mycode is this
std::map<std::string,myclass*> mymap;
size_t myfind(const std::string &s)
{
std::...
And how can I write my own array class to not need a default constructor for its elements? Right now, when I do the new [] to allocate space, I need a default constructor.
std::vector does not.
How do they do this magic?
...
Why when I watch the build output from a VC++ project in VS do I see:
1>Compiling...
1>a.cpp
1>b.cpp
1>c.cpp
1>d.cpp
1>e.cpp
[etc...]
1>Generating code...
1>x.cpp
1>y.cpp
[etc...]
The output looks as though several compilation units are being handled before any code is generated. Is this really going on? I'm t...
I have to port some crypto code to visual c++ from java which (visual c++) I am not very familiar with. I found a library at http://sourceforge.net/projects/cpp-bigint/ that I can use for big integers.
However it does not have an equivalent to javas SecureRandom class. I did find a project in c++ called beecrypt but could not get it ...
I am working on a application where-in i have to hit a URL and get the HTTP status code returned from that URL. Currently I am using WININET functions to achieve this. The code to achieve this:
hOpen = InternetOpenA("MYAPP", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
hFile = InternetOpenUrlA(hOpen, url.c_str() , NULL, 0,INTERNET_FLAG_RE...
In QtDemo there is an example called Dropsite in which an image can be dragged and dropped into the field to be displayed. This example used to work in an older version of Qt and works initially in 4.6 if you run it from qt\examples\draganddrop\dropsite\release folder. But if you load the project file into Qt Creator and recompile it, it...
Hi there,
I'm trying to solve this problem : http://uva.onlinejudge.org/external/7/732.html.
For the given example, they give us the original word, for example TRIT and the target "anagramed" string, TIRT.
Objective: We have to output all the valid sequences of 'i' and 'o' (push and pop's, respectively) which produce the target string ...
I'm writing a program to open up multiple files given at the command line. I first did it with array notation. That seems to work. Now I am trying to use compact pointer notation for practice and getting used to pointers, but I am not doing it right. Anyone want to tell me what I'm doing wrong? Thanks.
#include <cstdlib>
#include <f...
Case in point : I've got a handle to a window (for instance, using the getForegroundWindow() API function). This window's got a textbox (possibly a richtext control). Would it be possible to modify the textbox's text through an Windows API call ? More specifically, I'd like to replace its text with some of my own.
...
I am trying to create a trapezoid using user inputted options. I know my code may not be the best way but so far it works! My problem is i need the base of the trapezoid to be touching the left side of the output window. What am i doing wrong?
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
...
Hi I want to format float numbers such that it will be displayed as follows:
decimal.fraction
where decimal = max 11 digits and
fraction = max 9 digits
and if no fraction part it should display not fraction and for more than 11 digits in decimal part representation will be in scientific form.
Can anyone help me ?
...
Hello, I have an ActiveX object which extends some functions. I have a web page that loads the ActiveX object and calls its methods in Javascript. The ActiveX object has two method; the problem is that Javascript can successfully call one of them but fails to call the other; citing Object doesn't support this property or method which is ...
std::map<std::string, int> m;
// Can I make assumption that m["NoSuchKey"] will return 0?
std::cout << m["NoSuchKey"] << std::endl;
...
Is there any possible way of disabling multi core functionality on windows and just using a single core using C\C++? Any library that allows it?
My application access one of our chip modules used to communicate with the host. We suspect someone else is accessing this module and changes it. The strange thing is that it only happens on a m...
I'm hoping someone has run into this sort of problem before, and can give me a hint to solve it.
With Microsoft Visual C++ 2005, I have this code in a program:
DWORD locator[FOURXFLAGCOUNT+1]={
0x58585858, 0x58585858, 0x58585858, 0x58585858, 0x58585858,
0x58585858, 0x58585858, 0x58585858, 0x58585858, 0x58585858,
0x58585858,...
I want to create a GUI with C++ (QT4). The GUI should work on Windows and should be able to
create a database
use the database created by it (I should use an existing DBMS, in order not to worry for querries)
database should be specific to the GUI, other sowftwares should not be able to use that database (the database may be for examp...
Hi all.
I wish to use a COM dll in my C++ library.
The way I figured going about it, is to #import the dll's .tlb file, which I did :
#import "mycom.tlb" no_namespace
The problem is , I don't quite know where to place this declaration. should it be inside the H file or the CPP file? or maybe the stdafx.h file?
I tried placing it in ...
I try to determine the right most nth bit set
if (value & (1 << 0)) { return 0; }
if (value & (1 << 1)) { return 1; }
if (value & (1 << 2)) { return 2; }
...
if (value & (1 << 63)) { return 63; }
if comparison needs to be done 64 times. Is there any faster way?
...