So I'm trying to create a signal handler using pthreads which works on both OS X and Linux. The code below works on OS X but doesn't work on Fedora 13.
The application is fairly simple. It spawns a pthread, registers SIGHUP and waits for a signal. After spawning the signal handler I block SIGHUP in the main thread so the signal should o...
Can someone explain this behaviour?
test.c:
#include <stdio.h>
int main(void)
{
printf("%d, %d\n", (int) (300.6000/0.05000), (int) (300.65000/0.05000));
printf("%f, %f\n", (300.6000/0.05000), (300.65000/0.05000));
return 0;
}
$ gcc test.c
$ ./a.out
6012, 6012
6012.000000, 6013.000000
I checked the assembly code and it...
Hi,
I am searching a character at first occurence in string using the following code.
But it is taking some time when the character is too long or the character that I am
searching is at far extent, which delays other operations. How could I tackle this problem. The code is below here.
Note: attrPtr is a char * which holds a referenc...
#include <stdio.h>
void main()
{
int p[]={0,1,2,3,4};
int *a[]={p,p+1,p+2,p+3,p+4};
printf("%u %u %u",a,*a,*(*a));
}
What *(*a) will print(will it print 0 or it's address)?
And if we make array p as static(static int p[]), output gets changed .Why?
...
I've heard that objective-C is a proper superset of C, but is objective-C 2.0?
The reason I ask is that either it isn't, or I misunderstand the phrase 'proper superset', because this code is valid C syntax:
#import <stdio.h>
int main () {
char *nil = "hello";
printf("%s\n",nil);
}
But does not compile in Objective-C 2.0. Obv...
In C++, we have the abstraction and data hiding. Can we achieve this through C?
...
The following code manipulates pointers to point at the same location; I'm puzzled about why when I ran the code, the output didn't show value coinciding.
#include "stdio.h"
main()
{
int i=3,*x;
float j=1.5,*y;
char k='c',*z;
x=&i;
y=&j;
z=&k;
printf("\nAddress of x= %u",x);
printf("\nAddress of y= %u",y);
printf...
I have a function that is doing memcpy, but it's taking up an enormous amount of cycles. Is there a faster alternative/approach than using memcpy to move a piece of memory?
...
What are the differences (in performance, usability and functionality) in using #pragma once and #if !defined MYHEADER_INCLUDED_ constructs? Or what is the difference between the two?
...
i know it sounds crazy but, i just want to ask if is a compiler support multi programming language? like Delphi could also support C/C++/C# etc? if there is, please let me know. or how?
...
Possible Duplicate:
How to generate a random number from within a range - C
I'm looking for something I can use in C that will give me a random number between a and b. So something like rand(50) would give me a number between 1 and 50.
...
I've recently updated to a testing distribution, which is now using GCC 4.4.3. Now I've set everything up, I've returned to coding and have built my project and I get one of these horrible messages:
*** glibc detected *** ./boxyseq: free(): invalid pointer: 0x0000000001d873e8 ***
I absolutely know what is wrong here, but was rather con...
hi all,
I found this structure called OBJECT_ATTRIBUTE in one of the nt dll functions..I was curious to know about that structure and I went through its documentation(msdn)...In the OBJECT_ATTRIBUTE structure there is a parameter called PUNICODE_STRING objectName...As per the msdn documentation..it says that the objectName "the name...
I'm using the standard gcc compiler in math software development with C-language. I don't know that much about compilers or compiler options, and I was just wondering, is it possible to make faster executables using another compiler or choosing better options? The default Makefile sets options -ffast-math and -O3 and I think both of them...
Hello all ,
What are the techniques used to write an embedded C software which has multi features. Features can be configurable for multi-hardware platform.
I have developed a firmware based on a RTOS for ARM7. Now i want to make it a baseline firmware which can be used with similar, more or less features (configurable) on different mi...
Why infinite recursion leads to seg fault ?
Why stack overflow leads to seg fault.
I am looking for detailed explanation.
int f()
{ ...
Hello!
Is there any good plain C (or at least C++) library for parsing URL's that also supports IDN, so that it can easily parse url like http://президент.рф/
...
I tried to use the function called NTCreateFile. When I compiled it gave me an error saying
"_NTCreateFile identifier not found". I inlcuded the header winternl.h. So next I tried to use ZwCreatFile, as per MSDN I included ntifs.h, but I am not able to include that header. It says "not able to open/find the directory". I am using V@2008...
Say I had a library called libfoo which contained a class, a few static variables, possibly something with 'C' linkage, and a few other functions.
Now I have a main program which looks like this:
int main() {
return 5+5;
}
When I compile and link this, I link against libfoo.
Will this have any effect? Will my executable increase ...
I am using gsoap's wsseapi plugin and would like to store hashed sha1 passwords rather than plain text. I have spent a rediculous amount of time experimenting with various methods of hashing the plain text password for storage.
Can anyone suggest a way to hash a password so it can be later verified against a username token digest sent b...