If the bit pattern corresponding to a signed integer is shifted to the right then
1 vacant bit will be filled by the sign bit
2 vacant bit will be filled by 0
3 The outcome is implementation dependent
4 none of the above
The answer to this question is 3rd option.. Can anybody explain this,,
Also give some basic idea, abou...
Should a buffer of bytes be signed char or unsigned char or simply a char buffer?
Any differences between C and C++?
Thanks.
...
Out of curiousity, I'm reading the Zend Engine API code and encountered quite a number of ## in their #define's. For example, at /usr/lib/php5/Zend/zend_API.h:
#define ZEND_FN(name) zif_##name
#define ZEND_MN(name) zim_##name
What does the ## (double hash) symbols mean in these two lines?
...
Are there good open-source projects on P2P file-sharing systems or
distributed file systems written in C/C++ ?
I need a project to start with network-programming.
Can anyone give me any suggestions?
...
When we are compiling a C program the output is stored in a.out. How can we redirect the compiled output to another file?
...
I have written a little bit of C, and I can read it well enough to get a general idea of what it is doing, but every time I have encountered a macro it has thrown me completely. I end up having to remember what the macro is a and substitute it in my head as I read. The ones that I have encountered that were intuitive and easy to understa...
How can I find the factorial of a number (from 1 to 10) in C, without using:
loop statements like for, while, and do while;
conditional operators like if and case; and
arithmetic operators like + , − , * , % , /, ++, −−?
FYI: I found this question in C aptitude.
...
Is there a site that provides a great list of common C++ optimization practices?
What I mean by optimization is that you have to modify the source code to be able to run a program faster, not changing the compiler settings.
...
What would you suggest the best tool to profile C/C++ code and determine which parts are taking the most time. Currently, I'm just relying on logs but ofcourse the information is not accurate since unnecessary delays are introduced.
Preferrably, the tool would also be able to detect/suggest areas which could be optimized, if such tool e...
I am writing a program that's similar to a shell. Once started up, there's a prompt and you enter in some app-specific commands.
So far this works just fine. However, I want to add support for command history like in Bash, so the user could hit the up or down arrow and see previously entered commands.
I have included the ncurses libr...
What is the difference between these two file types. I see that my C++ app links against both types during the construction of the executable.
How to build .a files? links, references, and especially examples, are highly appreciated.
...
This has been something that has bothered me for ages now.
We are all taught in school (at least, I was) that you MUST free every pointer that is allocated. I'm a bit curious, though, about the real cost of not freeing memory. In some obvious cases, like when malloc is called inside a loop or part of a thread execution, it's very impo...
I have a third-party library which consists mainly of a large number of static (.a) library files. I can compile this into a single .a library file, but I really need it to be a single .so shared library file.
Is there any way to convert a static .a file into a shared .so file? Or more generally is there a good way to combine a huge n...
In a TC++ compiler, the binary representation of 5 is (00000000000000101).
I know that negative numbers are stored as 2's complement, thus -5 in binary is (111111111111011). The most significant bit (sign bit) is 1 which tells that it is a negative number.
So how does the compiler know that it is -5? If we interpret the binary value gi...
I see this flag a lot in the makefiles.
What does it mean? and when should it be used?
...
The situation I have is this: I'm redirecting input from one spot in my program to another through a pipe. However, it does not appear that this is working correctly, so I'd like to monitor what's going through the pipe.
Currently, I'm using dup2() to simply overwrite the stdin and stdout from the pipe.
How can I monitor what's going b...
I have this code in my main file:
int grid[] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
1 , 2 , 3 , 2 , 3 , 2 , 3 , 1 ,
1 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
1 , 0 , 1 , 0 , 1 , 0 , 1 , 1 ,
1 , 0 , 1 , 0 , 0 , 0 , 0 , 1 ,
1 , 0 , 0 , 0 , 0 , 0 , 1 , 1 ,
1 ...
For some long errors, the gcc output is dense and has lots of line-wrapping etc. Especially when errors are subtle, it can take me 10-30 seconds of squinting to parse it with my eyes.
I've taken to pasting this in an open code-editor window to get some basic syntax highlighting and enable reformatting with regex's.
Has anyone invented...
Not sure if this is phrased well or not...
In most modern shells, you can hit the up and down arrows and it will put, at the prompt, previous commands that you have executed. My question is, how does this work?!
It seems to me that the shell is somehow manipulating stdout to overwrite what it has already written?
I notice that progra...
Briefly:
I'm after the equivalent of .NET's String.Trim in C using the win32 and standard C api (compiling with MSVC2008 so I have access to all the C++ stuff if needed, but I am just trying to trim a char*).
Given that there is strchr, strtok, and all manner of other string functions, surely there should be a trim function, or one t...