I am converting a number to binary and have to use putchar to output each number.
The problem is that I am getting the order in reverse.
Is there anyway to reverse a numbers bit pattern before doing my own suff to it?
As in int n has a specific bit pattern - how can I reverse this bit pattern?
...
As i am new to c++ ,i am quite confused with the dynamic_cast keyword in c++.
struct A {
virtual void f() { }
};
struct B : public A { };
struct C { };
void f () {
A a;
B b;
A* ap = &b;
B* b1 = dynamic_cast<B*> (&a); // NULL, because 'a' is not a 'B'
B* b2 = dynamic_cast<B*> (ap); // 'b'
C* c = dy...
Hi
Why result of
include <stdio.h>
int main()
{
unsigned short int i = 0xff ;
unsigned short int j;
j= i<<2;
printf("%x n%x\n", i, j);
return 0;
}
is j = 3fc ?
if both i and j are short int - so they are 2bytes values, so j shouldnt =fc ??
thx in advance for explanations.
~
~
...
I have a collection of dynamic libraries that I want to link to in /usr/local/lib, how can I do this using gcc without setting my LD_LIBRARY_PATH (i have heard it is bad to do this fora number of reasons).
I have spent an hour looking at this on the internet, and fiddling with command line arguments, the only way I got it to work was usi...
hi ,
int * (*) (int * , int * (*)())
I'd like to know what type is it ? , can someone give an example of a declaration using this type.
any help would be great.
thanks.
...
Our application is a C server (this problem is for the Windows port of said server) that communicates with a Windows Java client. In this particular instance we are sending data to the client, particularly, the message consists of a 7 byte header where the first 3 bytes all have a specific meaning (op type, flags, etc) and the last 4 by...
I recently inspect a GUI with Microsoft's Spy++ and noticed a strange structure; it looked like this (warning, ASCII art ahead):
|
+ 002004D6 "MyRootWindow1" FooClassName
| |
| + 001F052C "MyChildWindow" ClassOfChildWindow
|
\ 001D0A8C "MyRootWindow2" SomeOtherClassName
There are two root windows, 002004D6 and 001D0A8c, the...
One project should be compiled for Windows, Linux and an embedded target. The application has behavior differences when running on host or embedded targets. To summarize my requirements, here is the table:
Target Compiler Behavior
Windows MSVC, gcc A
Host Linux gcc ...
I have these 2 sequences for a binary tree (not a BSD):
InOrder: 3 2 1 4 5 7 6
PostOrder: 3 1 2 5 6 7 4
We know that the last element in postOrder is the root, so we locate the root at the inOrder sequence and subdivide like this:
- all the elements at the left of the root go to the left subtree
- all the elements at the right of the ...
I have some C++ code that I found that does exactly what I need, however I need it in C and I do not know how I could do it in C, so I am hoping someone can help me out.
The C++ code is:
std::string value( (const char *)valueBegin, (const char *)valueEnd );
This is using the string::string constructor:
template<class InputIterator> ...
Hi,
I would like to know if there is a way to embed Mercurial tags into my C/C++ code.
Basically I would like the tag string, which will end up being a release number (major.minor.rev), to be automatically inserted in a determined location of my C code as a static string.
The overall objective is that the application could be querie...
Is it possible to add a #define _MYDEFINE_ in my header file based on some options in the project settings. For Ex: Suppose in my exposed header file (which is delivered along with the library) I have some macros like shown below:
#ifdef _MYDEFINE_
#define ABC 2
#else
#define ABC 4
#endif
Now, while building my library, I can add _MYD...
As far as I can see there are 3 ways to use booleans in c
with the bool type, from then using true and false
defining using preprocessor #define FALSE 0 ... #define TRUE !(FALSE)
Just to use constants directly, i.e. 1 and 0
are there other methods I missed? What are the pros and cons of the different methods?
I suppose the fastest...
What are the points that should be kept in mind while writing code that should be portable on both 32 bit and 64 bit machines?
Thinking more on this, I feel if you can add your experience interms of issues faced, that would help.
Adding further on this, I once faced a problem due to a missing prototype for a function which was returnin...
I have two debian boxes connected by a CX4 cable going between two 10 GbE cards. One is going to be generating data very quickly (between 4Gbits/s and 16Gbits/s), and the other needs to be able to grab all of that and store it in RAM for later parsing. I'm new to this kind of low-level coding, and would happily accept any ideas about w...
hi i was running cuda program on a machine which has cpu with four cores, how is it possible to change cuda c program to use all four cores and all gpu's available? i mean my program also does things on host side before computing on gpus'...
thanks!
...
In another post link text
I am trying to do the same thing with a struct, but I have a problem with my sizeof operator, so in the integer case, I did this:
size_t totalMem = rows * sizeof(int *) + rows * cols * sizeof(int));
And in the struct case I did this:
size_t totalMem = (rows * sizeof(struct TEST *)) + (rows * cols * sizeof(s...
The @encode directive returns a const char * which is a coded type descriptor of the various elements of the datatype that was passed in. Example follows:
struct test
{ int ti ;
char tc ;
} ;
printf( "%s", @encode(struct test) ) ;
// returns "{test=ic}"
I could see using sizeof() to determine primitive types - and if it was a full ...
Is there a cross platform C API that can be used to get system usage metrics?
...
Hi,
What is the advantage of zeroing out memory (i.e. calloc over malloc)? Won't you change the value to something else anyways?
-Chris
...