c

Is ARPACK thread-safe?

Is it safe to use the ARPACK eigensolver from different threads at the same time from a program written in C? Or, if ARPACK itself is not thread-safe, is there an API-compatible thread-safe implementation out there? A quick Google search didn't turn up anything useful, but given the fact that ARPACK is used heavily in large scientific ca...

2D Arrays and Pointers - C

Hi there, Just trying to really get my head round Arrays and Pointers in C and the differences between them and am having some trouble with 2d arrays. For the normal 1D array this is what I have learned: char arr[] = "String constant"; creates an array of chars and the variable arr will always represent the memory created when it wa...

When is malloc necessary in C?

I think all malloc(sizeof(structure)) can be replaced this way: char[sizeof(structure)] Then when is malloc necessary? ...

How to approach debugging a huge not so familiar code base?

Seldom during working on large scale projects, suddenly you are moved on to a project which is already in maintainance phase.You end up with having a huge code C/C++ code base on your hands, with not much doccumentation about the design.The last person who could give you some knowledge transfer about the code has left the company already...

The usage of sig_atomic_t in linux signal mask function

I was recently studying the book named Advanced Linux Programming and I ran into this question: The book said you should use sig_atomic_t variable type to be sure that if you set a global flag or counter in a signal handler function, context switch does not occur between the arithmetic operations(i.e. ++) and saving those into a register...

Issue with NULL pointers on Harvard Architecture platform

Interesting issue we came across here this week. We are working in C on a Harvard Architecture embedded platform, which has 16-bit data addresses and 32-bit code addresses. The issue occurs when you are working with function pointers. If you have code like if (fp) fp(); or if (fp != 0) fp(); everything is fine. However if you ...

Malloc, free and segmentation fault

Hi, I don't understand why, in this code, the call to "free" cause a segmentation fault: #include <stdio.h> #include <string.h> #include <stdlib.h> char *char_arr_allocator(int length); int main(int argc, char* argv[0]){ char* stringa = NULL; stringa = char_arr_allocator(100); printf("stringa address: %p\n", stringa);...

Please help in strtok()

Please explain me the working of strtok() function.The manual says it breaks the string into tokens. I am unable to understand from the manual what actually it does. I added watches on str and *pch to check its working, when the first while loop occurred, the contents of str were only "this". How did the output shown below printed on th...

Finding the smallest integer that can not be represented as an IEEE-754 32 bit float

Possible Duplicate: Which is the first integer that an IEEE 754 float is incapable of representing exactly? Firstly, this IS a homework question, just to clear this up immediately. I'm not looking for a spoon fed solution of course, just maybe a little pointer to the right direction. So, my task is to find the smallest positi...

what will be the output & why

_ #include<stdio.h> int main() { int a=5,b=10; printf("%d %d"); return 0; } ...

Query regarding main() of GRUB

Below is the code of main() of grub. Here I want to know about this line: file = fopen(arg_v[1], "rb"); Here which file fopen is opening? What file this arg v[1] is pointing to? int main(unsigned arg_c, char *arg_v[]) { FILE *file; if(arg_c < 2) { printf("Checks if file is Multiboot compatible...

How to ensure that when my process is operating on a file, no other process tries to write to it or delete it?

If my process is trying to read from a file, then how do I ensure from my code (C Language) that no other process either writes to it or deletes it (include system commands for deleting the file)? Also, can this be achieved on all OS (Windows, Linux, Solaris, HP-UX, VxWorks etc)? ...

Why such illicit output comes?

Possible Duplicate: what will be the output & why #include<stdio.h> int main() { int a=5,b=10; printf("%d %d %d %d %d %d"); return 0; } output: 10 5 0 344 0 0 ...

Convert from C++ style printing to my_printf()

C++ purists may want to look away now. You will hate this. I have been given an open source windows console app that I am merging with a pre-existing, very old, very large windows app of my own. My old program started life as pure C though recently has been tweaked so that it can compile as C++. My program makes extensive use of a my_pr...

Microsoft .net, is it worth it?

So with Microsoft .NET, you get the advantage of language interoperability. But I've heard that this is slower than native applications. What if you only need one language? Then what are the advantages. I am a C and C++ programmer, and .net seems to be heavily tied with C#. Is this the case? And is dot net portable, or tied to windows? ...

Increment and Decrement Operators

#include<stdio.h> main () { int x=4,y,z; y = --x; z = x--; printf ("\n %d %d %d", x,y,z); } output 2,3,3 Can anyone explain this?? And what does this : i=+j; means (suppose i = 1 and j =2) ...

How does C-- compare to LLVM ?

After learning a bit of how LLVM work I'm really excited about how portable low-level code can be generated and how modular this 'things' is built. But I discovered today the existence of C-- that seems to share some concepts with LLVM. So I'm looking for some informations helping me to understand the main differences between this two ...

using winAVR and AVR studio 4 how to compile code written in C

I have installed winAVR and AVR studio 4 for compiling code written in C for but i can't simulate it there is error"mega32.h-no such file or directory" ...

C : sprintf inside printf as first argument

Learning C at University. This is not a homework, but I was trying to do something (some "creative" part of the assignment) and got stuck. I understand that this is possible printf("%d\n", printf("23.4")); // -> 23.44 (i.e. 23.4 + 4 bytes written) but how can I use sprintf() as first argument of printf() ? something like : char * g...

Causing a divide overflow error (x86)

I have a few questions about divide overflow errors on x86 or x86_64 architecture. Lately I've been reading about integer overflows. Usually, when an arithmetic operation results in an integer overflow, the carry bit or overflow bit in the FLAGS register is set. But apparently, according to this article, overflows resulting from divis...