c

Intimation from PSQL trigger

In my program, I am accessing Postgresql database. I don't want to watch database regularly, So When ever the specified table get changed by various actions ( insert, update, delete ), I need to get some signal or message to my program, So I have an idea to use Triggers, But I don't know how to send signal or API or message to my prog...

why select() always return 0 after the first timeout

I have a problem about select function when I worked on a Linux socket program. The select function worked fine as the man page says if the client connected the server side in the time interval configured by the server. If the timeout happened, the select function will return 0 forever. At that time, I debug the client and find the clie...

confusion about static variables

I have a confusion in the concepts of static integer.When i initialize a static integer in main function i.e static int i; Now the static integer is assigned a value 0.Now in the next step: i+1; i becomes 1. Now the program terminates.My question is WHAT WILL BE THE VALUE OF I FOR THE NEXT RUN OF THE PROGRAM? also what if i close ...

how to build a calculator in GTK+?

what's the logic behind the calculator widget. i want to build it in gtk+. ...

Implement Scrolling text in C

Hii , I was asked this question in one of my interviews with a MNC recently . The question was " We need to display a screen in which a text scrolls at the bottom of the screen and the remaining screen is empty . How would you accomplish this in C ? What data structures would you use ..?? " Any ideas please ...! ...

Unix Domain Socket: Using datagram communication between one server process and several client processes

I would like to establish an IPC connection between several processes on Linux. I have never used UNIX sockets before, and thus I don't know if this is the correct approach to this problem. One process receives data (unformated, binary) and shall distribute this data via a local AF_UNIX socket using the datagram protocol (i.e. similar t...

How can I determine if process is 32 or 64Bit from a handle?

How can I get the information from a Process handle acquired using OpenProcess whether a Process is 32 or 64 Bit? ...

Concatenate two char arrays?

Hey all, If I have two char arrays like so: char one[200]; char two[200]; And I then want to make a third which concatenates these how could I do it? I have tried: char three[400]; strcpy(three, one); strcat(three, two); But this doesn't seem to work. It does if one and two are setup like this: char *one = "data"; char *two = "m...

strlen in array

I'm debugging a code in which a .ini file is being read for the value of string called Timeout(which is taken into a varibale called rbuf).Please tell me the content of the .ini file when the condition is as follows: if((strlen(rbuf) > 0) && (rbuf[strlen(rbuf)-1] == '\n')){ rbuf[strlen(rbuf)-1] = '\0'; } When will the debugger ...

Compiling for windows 64bit target, issues with static .libs

Hi, I'm using MS Visual Studio 2008 professional edition on windows 7 64bit. I installed the 64 bit compilers along with the standard 32bit ones. I have used http://argtable.sourceforge.net/ for windows 32bit programs before I have no problems building my application (Which is just written in plain and simple C89) to use argtable2.lib ...

Should I learn to implement OOP in C? Are there projects that use OOP in C?

Recently, I finished reading K&R with its, almost all, exercises and examples. I was planning to move to "Accelerated C++" that I came across Axel Schreiner's book OOP with ANSI-C. I am intrigued and want to learn it. But before investing time in it, I want to know the worth of implementing OOP in C. So that I can decide how much time I...

Problem with writing a 16bit raw PCM file

As a small experimental music piece I am attempting to program a song in standard C. The code outputs a raw PCM file which can be imported into Audacity. At the moment everything works as expected, but I'm encountering problems when trying to write each sample as 16 bit as opposed to the current 8 bit I am using. Up until the point of b...

What is the relation between PATH_MAX and NAME_MAX, and how do I obtain?

In limits.h, and in various places in the POSIX manpages, there are references to PATH_MAX and NAME_MAX. How do these relate to one another? Where is the official documentation for them? How can I obtain them at run time, and (where relevant) compile time for the C, Python, and GNU (shell) environments? ...

LP64, LLP64 and the IL32 transition

During the transition from 16 to 32 bit in the 80s, int was either 16 or 32 bit. Using the current 64 bit transition nomenclature, I understand there was a pretty even spread of ILP32 and LP32 machines. At the time I believe it was understood that int would always follow the register or pointer width for any given architecture and that l...

Behavior of an expression: Defined or Undefined?

I have the following code int m[4]={1,2,3,4}, *y; y=m; *y = f(y++); // Expression A My friend told me that Expression A has a well defined behavior but I am not sure whether he is correct. According to him function f() introduces a sequence point in between and hence the behavior is well defined. Someone please clarify. P.S: ...

what does double underscore mean in variable name in c language

Possible Duplicate: Why do people use __(double underscore) so much in C++ I was studying the linux kernel programming code. There aere some data structures and function which starts with double underscore(_ _) like _ _ u32 len how that is different from normal variables ...

C++: extern and inline functions

I have a couple of files written in C, and I want them to be C++-compatible, so for my C headers I use; #ifdef __cplusplus extern "C" { #endif at the beginning of the file and of course #ifdef __cplusplus } #endif ...at the end. But it seems to create problems with the 'inline' keyword. My solution is to simply remove the inline k...

C: signal function (parameters?)

I have the following c code: void handler(int n) { printf("n value: %i\n"); } int main() { signal(SIGTSTP, handler); // ^Z at keyboard for(int n = 0; ; n++) { } } I am curious what the n parameter is in the handler function. When you press ^Z it usually prints either: 8320, -1877932264 or -1073743664. What are ...

C const/non-const versions of same function

Suppose in C I have the functions type* func (type*); const type* func_const (const type*); such that they both have the exact same internal logic. Is there a way I can merge the two into one function, where if given a const type, it returns a const type; and if given a non-const type, it returns a non-const type? If not, what is a g...

Match sub-string within a string with tolerance of 1 character mismatch

Hi, I was going through some Amazon interview questions on CareerCup.com, and I came across this interesting question which I haven't been able to figure out how to do. I have been thinking on this since 2 days. Either I am taking a way off approach, or its a genuinely hard function to write. Question is as follows: Write a function i...