c

Problems running a C program on Debian

Hello, I have a following problem: I compiled my application on Linux Ubuntu 9.10 using CodeBlocks. It is a C program (which uses few libraries, like libmysql, jasper...) I copied the compiled program to a remote system running Debian 2.6.18, chmodded +x the application but when calling ./my_app bash still says "No such file or director...

GCC generated assembly equivalent to continue statement in C

When a continue statement is used inside a loop in C code, GCC creates a new label with a nop instruction right before the end of the loop block and jumps to it, rather than jump to the end of the loop block itself. For instance, the following C code for (i=0; i<10; i++) { puts("blah\n"); if (i < 10) continue; puts("This sho...

xUnit testing framework for C

Hi all! I'm developing a fairly simple C project for an embedded device. I'd like to employ xUnit testing. I've settled down with the Check framework (http://check.sourceforge.net/), but it seems it doesn't support function stubs. I remember using a very syntactically similar framework a few years ago that supported stubs, but i can't r...

conditional compilation statement in limits.h

I am not able to understand the following statement from the file limits.h. What is the use of this statement and what does it accomplishes? /* If we are not using GNU CC we have to define all the symbols ourself. Otherwise use gcc's definitions (see below). */ #if !defined __GNUC__ || __GNUC__ < 2 ...

Why does scanf not terminate when I expect it to

If I write a C program then it will not automatically get out of if else like .... #include<stdio.h> int main () { int a, b, c, d; printf ("enter the value "); scanf("%d %d %d ",&a,&b,&c); d=a+b+c; if(d==180) printf("triangle is valid "); else printf("triangle is invalid "); return 0; } then it will not termin...

typecasting to unsigned in C

int a = -534; unsigned int b = (unsigned int)a; printf("%d, %d", a, b); prints -534, -534 Why is the typecast not taking place? I expected it to be -534, 534 If I modify the code to int a = -534; unsigned int b = (unsigned int)a; if(a < b) printf("%d, %d", a, b); its not printing anything... after all a is less than b?? ...

Migrating DB2 UDFs from AIX to Linux (RHEL)

I successfully compiled some UDFs on 64-bit Linux that were originally compiled on AIX Linux is running IBM DB2 v9.5 Here's the function that sometimes returns for some values #include <cstdlib> #include <cstdio> #include <iostream> #include "cbudf.hpp" using namespace std; extern "C" void SQL_API_FN cbzdt(SQLUDF_VARCHAR_FBD *pArg,...

"unable to open stdio.h in turbo c"

whenever i compile my program i get the error above,plz give some solution. ...

Recursive harmonic function returns NaN

Hi, I have written the following sample code to find the harmonic value of N. (1+1/2+1/3+...1/N). Read the comments in the code written in BOLD and help me to find why is this happening. #include <stdio.h> float harmonic(float n, float har) { if(n==0) { return 0; } if(n==1) { printf("%f\n", har+1.0f);***/...

Find original owning process of a Linux socket

In Linux and other UNIX-like operating systems, it is possible for two (or more) processes to share an Internet socket. Assuming there is no parent-child relationship between the processes, is there any way to tell what process originally created a socket? Clarification: I need to determine this from "outside" the processes using the /p...

Do I need to #include <omp.h> in my C/C++ sources?

Is it necessary to include omp.h in my C/C++ sources? Why? Or why not? Does the gcc compiler include it by default when used with the -fopenmp flag? It doesn't seem te make a differance. ...

Can I share a file descriptor to another process on linux or are they local to the process ?

Say I have 2 processes, ProcessA and ProcessB. If I perform int fd=open(somefile) in ProcessA, can I then pass the value of file descriptor fd over IPC to ProcessB and have it manipulate the same file? ...

What are *-devel packages?

What is the utility of devel packages like "libgtk+-devel" or "python-devel" etc.? Do they contain source of the library? How is it different from non-devel packages like libgtk+? ...

Screen is flickering even when using doublebuffering

I am totally new in programming. For my first programm I tried to make a small game in c with windows api. the following code is a nearly working snake, (some bugs not fixed yet) but i cant find a working solution to fix that flickering. (I dont know double Buffering so I just took from here: [http://www.codeguru.com/forum/archive/index....

Lex: How do I Prevent it from matching against substrings?

For example, I'm supposed to convert "int" to "INT". But if there's the word "integer", I don't think it's supposed to turn into "INTeger". If I define "int" printf("INT"); the substrings are matched though. Is there a way to prevent this from happening? ...

How do I check if a program has already been executed during the current login session? (Windows)

In an application I am developing (in C), a loader app must first be run before the main application is executed. I have made it so the main app runs the loader app as a child when it is launched in order to automate this task. This all works well, except for the fact that the loader app only needs to be run one time during the user's cu...

calling ptrace inside a ptraced Linux process

Someone added to the Wikipedia "ptrace" article claiming that, on Linux, a ptraced process couldn't itself ptrace another process. I'm trying to determine if (and if so why) that's the case. Below is a simple program I contrived to test this. My program fails (the sub sub process doesn't run properly) but I'm pretty convinced it's my ...

Working with GNU regex functions in C or C++

Can anyone give me complete example program how to work with GNU regex functions in gcc C or C++ (http://docs.freebsd.org/info/regex/regex.info.GNU_Regex_Functions.html), with re_pattern_buffer, re_compile_fastmap? For example, translate this small Python program: import re unlucky = re.compile('1\d*?3') nums = ("13", "31", "777", "1...

How do I make a custom system wide mouse cursor animation?

I write software for the disabled. One of the problems is difficulty tracking the mouse pointer. I want to have the mouse cursor glow (or similar effect. Maybe water like ripples around it) when the user needs to locate it. How is this done? I know it's possible because it's used in a variety of software. ...

C programming structure passed as cast to char * ?

I have a little problem, in a scenario where: while (read(dp->fd, (char *) &dirbuf, sizeof(dirbuf)) == sizeof(dirbuf)) { ... } where dirbuf is: struct direct dirbuf { ino_t d_ino; char d_name[DIRSIZ]; }; How does C know to read in data contingently into our structure? With the read() Like, the alignment of our dirbuf fits ...