c

Improving the performance of C code...

What is the most unorthodox way to improve the performance of C code? This is no-holds-barred! Everything goes including changing loop structures to gotos, hardcoding anything and everything, using case statements in bizarre ways etc. Don't worry at all about maintainability, readability etc. p.s. This is practical... and I'm well awa...

How can i Compile a C program on Dos prompt using tcc and tc

I want to compile c program on dos prompt using tcc as well as tc without using c editor. please give the full procedure. ...

Question on extern specifier in C

How does the following example usage of extern specifer behave. We have a global variable int x both in files one.c and two.c We want to use these in three.c so have declared this variable in three.c as extern int x; What would happen when we compile and link these files? My answer is: compilation of all these files should succe...

Overflow over scanf("%8s", string)?

Hi, I know it's possible to overflow ordinary code: char string[9]; scanf("%s", string). But is it possible to overflow scanf("%8s", string)? 8 is just an example. I know "%8s" works like a delimit, but I also notice when I input string longer than 8 chars, the program will terminate due to: * stack smashing detected *: ./a.out ter...

Pthreads C/C++ compilation problem

Hello, I'm getting error "undefined reference to `pthread_attr_init'", even though that should be in pthread.h. This is in a UNIX environment that should be set up for Pthreads. Also, is a void* a good way to point to the current matrix? Here's my code, any ideas? #include <cstdlib> #include <iostream> #include <sstream> #include <strin...

C library function to do sort

Is there any library function available in C standard library to do sort? ...

Recursive function that divides two numbers, using successive subtraction

I have tried but failed to do so. Could I have a push in the right direction? ...

When to use malloc for char pointers

I'm specifically focused on when to use malloc on char pointers char *ptr; ptr = "something"; ...code... ...code... ptr = "something else"; Would a malloc be in order for something as trivial as this? If yes, why? If not, then when is it necessary for char pointers? ...

how the code behaves different for java and C compiler ?

I have this Code, i ran this on Java and C ,but they give me two different Results What is that makes them to run differently. x=10;y=10;z=10; y-=x--; z-=--x; x-=--x-x--; The Output in java for value of X is : 8 and for C it is 6 How these Two compiler Behaves differently for incremented options.?. ...

Is system programming dead?

I am asking here from the perspective of a C programmer using mostly Unix. Is it still worth it to do system programming in C? ...

audio comparison

How to compare two audio files to see the difference of them ...

Can doubles be used to represent a 64 bit number without loss of precision

I want to use lua (that internally uses only doubles) to represent a integer that can't have rounding errors between 0 and 2^64-1 or terrible things will happen. Is it possible to do so? ...

How does make know which files to update

I noticed that when I make changes to some files and then I type make, it will run certain commands related to those files. If I don't change anything, then make doesn't do anything, saying that the program is up to date. This tells me that make has a way of knowing which files were changed since it was last run. How does it know? It...

Function pointer as an argument

Hi all.. i am working in embedded C environment.. can we pass function pointer as an argument to a function in C? if so, can u give me a sample declaration and definition.. thnx in advance ...

In C is "i+=1;" atomic?

In C, is i+=1; atomic? ...

How to use strtol to read from an __int64 value ?

Do exist on msvc and mingw a 64 bits equivalent function to do it ? Aparently K&R was thinking that 2^32 was enough ...

How to detect if a Bluetooth HID device was disconnected?

I'm using CreateFile to open an asynchronous file handle to a Bluetooth HID device on the system. The device will then start streaming data, and I use ReadFile to read data from the device. The problem is, that if the Bluetooth connection is dropped, ReadFile just keeps giving ERROR_IO_PENDING instead of reporting a failure. I cannot re...

what is the difference between read() and recv() , and between send() and write() ?

what is the difference between read() and recv() , and between send() and write() in socket programming ? performance and speed and other behavior. ...

Popup window appearing while stopping the C process

I am calling a C process from my Java program, and ending that C process using exit (0). On Windows machine, under certain conditions it is opening a pop-up window telling me that "Test.exe has encountered a problem and needs to close. We are sorry for the inconvenience." Does anyone have a guess why this problem is coming around? I ...

DHCP client doesnt receive response on port 68

I have used wireshark to see the DHCP packet structure. Now I have created a DHCPDISCOVER request and stored it in 'message'. I then broadcast it on the network. sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd < 0) { perror("socket"); exit(1); } setsockopt(sockfd,SOL_SOCKET,SO_BROADCAST, &on,sizeof(on)); setsockopt(sockfd,SOL_...