Take the following :
#include <stdio.h>
main() {
unsigned long long verybig = 285212672;
printf("Without variable : %llu\n", 285212672);
printf("With variable : %llu", verybig);
}
This is the output of the above program :
Without variable : 18035667472744448
With variable : 285212672
As you can see from the a...
How can I find a binary tree from a given traversal method (inorder,post-order,pre-order)?
...
I've been reading through beejs guide to networking to get a handle on TCP connections. In one of the samples the Client code for a simple TCP stream client looks like:
if ((numbytes = recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) {
perror("recv");
exit(1);
}
buf[numbytes] = '\0';
printf("client: received '%s'\n",buf);
cl...
Can I force the gcc to use a null canary or terminator canary, when SSP is enabled, instead of random canary? If so, how?
...
When trying to run M-x Flymake-Mode in Emacs I get:
Flymake: Configuration error has occured while running (make -s -C ./CHK_SOURCES=helloworld_flymake.c SYNTAX_CHECK_MODE=1 check-syntax). Flymake will be switched OFF
I am invoking the command in a buffer called helloworld.c:
#include <stdio.h>
int main(void) {
printf("Hello World...
Hi,
I need help doing the following:
a preprocessor macro label(x) shall output "#x", e.g.,
#define label(x) ...
if I call label(aname), the output shall be "#aname"
I know, that the following tries were errors.
#define label(x) #x // leads to "x"
#define label(x) \#x // is \"x"
#define label(x) "#x" // is "#x" (but not the cont...
Are there any good memory fragmentation profilers? (linux gcc version would be nice). Valgrind cannot analyze this because it uses custom malloc/free functions.
Thanks,
Andrew
...
I have some binary files that I'd like to embed in a dll I'm compiling with VC++ Express Edition.
I have a couple ways to do it (like converting the data to arrays that I compile along with the code), but I'm not satisfied and I feel like I'm probably missing an easy, straightforward solution.
What's the cleanest, easiest way to do thi...
Hi, how could the last error message be printed?
It gives me an integer instead of a text message.
Thanks.
...
Many times I work with optimized code (sometimes even involving vectorized loops), which contain bugs and such. How would one debug such code? I'm looking for any kind of tools or techniques. I use the following (possibly outdated) tools, so I'm looking to upgrade.
I use the following:
Since with ddd, you cannot see the code, I use gd...
I am trying to debug a segfault, and I have this output from gdb:
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
0x08048af9 in parse_option_list (ptr=0x6f72505f <Address 0x6f72505f out of bounds>, box_name=0x696d6978 <Address 0x696d6978 out of bounds>, option_list=0x313a7974,
num_elements=0x33313532) at submit.c:125
...
I have never really done much C but am starting to play around with it. I am writing little snippets like the one below to try to understand the usage and behaviour of key constructs/functions in C. The one below I wrote trying to understand the difference between char* string and char string[] and how then lengths of strings work. Furth...
Hello, I want to learn more about using the SSE.
What ways are there to learn, besides the obvious reading the Intel® 64 and IA-32 Architectures Software Developer's Manuals ?
Mainly I'm interested to work with the GCC X86 Built-in Functions.
...
I need to create an assembly function that adds two positive numbers together, called by a C program.
The C program would look like this:
#include <stdio.h>
int main(void){
int a = 0;
int b = 0;
int c = 0;
printf( "Enter first number: " );
scanf( "%d", &a );
printf( "Enter second number: " );
scanf( "%d", &b );
sum();
printf( "Answer ...
I'm reading in an NES ROM file, where the first four bytes are "\x4e\x45\x53\x1a", or NES\x1a. In my actual code, the given file can be arbitrary, so I want to check to make sure this header is here. However, I'm running into some trouble, which the following code demonstrates:
#include <stdio.h>
#include <string.h>
int main()
{
FILE ...
I've heard that game developers will sometimes replace parts of inner loops w/ assembly code to improve the performance.
What is a simple example of this?
Where does the assembly go? Just inline w/ the c code?
Thanks!
Edit: a code sample is greatly appreciated.
...
Is there any way to pass a callback to java code, from C. And the call returns immediately. Later on, after completing the task, the java code can invoke that callback.
I have a C extension for php that calls a java store to store some items in it. The items can be retrieved from store in synchronous and asynchronous methods (I provide...
I'm responsible for a number of legacy C based GTK applications which are starting to show their age. I'm toying with the idea of re-implementing some of them in a more modern framework. Are there any tools which can help migrate a hand-built C based GTK interface into a GTK Builder based XML interface description? My aim would be to sep...
I'm working on a socket program and everything seems fine.However after i compiled and run the server, i compile and run the client. But there is a problem in connect() function and even socket is ok client does not connect or server does not accept connection...
While compiling, i got no errors.
but after client has ran : error is
...
Hi,
I'm a scientist who is quite comfortable with C for numerical computation, but I need some help with displaying the results. I want to be able to display a continuously updated bitmap in a window, which is calculated from realtime data. I'd like to be able to update the image quite quickly (e.g. faster than 1 frame/second, preferab...