c

How to get virtkey value for WM_KEYDOWN in WS_CHILD?

I want to know the value of virtual key pressed when a child window(like 'edit' or 'button') has focus. How to do that? ...

How to read a file line-by-line in C?

Okay, I'm a beginner when it comes to C, so bear with me. Here's the problem: I have a text file with up to 100 IP addresses, 1 per line. I need to read each address, as a string, into an array called "list". First, I'm assuming that "list" will need to be a two-dimensional char array. Each IP address is 11 characters in length, 12 if y...

How can I cause ldap_simple_bind_s to timeout?

We recently had a problem with our test LDAP server - it was hung and wouldn't respond to requests. As a result, our application hung forever* while trying to bind to it. This only happened on Unix machines - on Windows, the ldap_simple_bind_s call timed out after about 30 seconds. * I don't know if it really was forever, but it was at ...

fopen two processes

Is it ok to have two processes writing to same file multiple times in a certain span of time usign fopen(append mode), fprintf, fclose functionality. they wait for data and repeat the open,write,close operation. is there a chance of data not being written? ...

Parse Apache Log in Ansi C

Does anyone have a snippit of code to parse apache2 logs with ANSI C? ...

Windows: How big is a BOOL?

How big (in bits) is a Windows BOOL data type? Microsoft defines the BOOL data type as: BOOL Boolean variable (should be TRUE or FALSE). This type is declared in WinDef.h as follows: typedef int BOOL; Which converts my question into: How big (in bits) is an int data type? Edit: In before K&R. Edit 2: Somethi...

Randomly disappearing struct

Hi, I've created a Objective-C class to interface with PostgreSQL using libpq. It mostly works but I have one small problem - the connection seems to disappear randomly. This class is set to open a connection when a window is opened and close that connection before the window closes. On the init code of the window I open the connection...

Is there a difference between a "child control", a "child window" and a "child window control"?

Or are these terms used to refer to the same thing? I'm trying to implement some custom buttons showing a bitmap image, into my Win32 app. One tutorial indicates I should be creating child windows using CreateWindow(). However, I have downloaded a bunch of source code from another tutorial on creating "child controls", and no referenc...

Why would buffer overruns cause segmentation faults when accessing an integer?

During a call to function B() from function A(), B() allocates a 100-char array and fills it several times, including once with a 101-character string and once with a 110 character string. This is an obvious mistake. Later, function A() tries to access completely unrelated int variable i, and a segmentation fault occurs. I understand ...

EXIT_SUCCESS for function return?

Hi, I know EXIT_SUCCESS/EXIT_FAILURE is typically used for main() exit to indicate the successfulness of a program. But is it also used (commonly or suggested) for normal function returns? I'm trying to write some "standard" code so wondering if I should use them instead of 0 or -1.. Thanks. ...

C-programming ftell fseek fread, read size of a file

I have a file. I read the size of file. Then I loop reading two bytes at a time until I get to the end of the file. After every read operation I increment the current position by 2, however the position does not get incremented after I get to half the size of the file, the fread operation will read 0 bytes. the program reads the file si...

Assisting in avoiding assert... always!

In C and C++ assert is a very heavyweight routine, writing an error to stdout and terminating the program. In our application we have implemented a much more robust replacement for assert and given it its own macro. Every effort has been made to replace assert with our macro, however there are still many ways assert can be reintroduced (...

#include iostream in C?

In C++ we always put the following at the top of the program #include <iostream> What about for C? ...

c statements not recognized in yacc file

On some linux machines when I compile my yacc program it works fine. However, on other machines, I noticed that none of the c statements that are interspersed with the grammar rules are ever executed, even printf. What could be the problem? I noticed that on these machines I have to take out the -ly option because it gives an error if...

sending a signal to a background process

Which signal should I send to a background process to move it foreground? SIGTTIN, SIGTOU or...? ...

Compilers for DOS32?

Where can I get BASIC and C/C++ Compilers for MS-DOS? ...

Difference between modifying a structure by reference versus other pointers

I am wondering why a structure pointer seems to be behave differently than a char pointer. typedef struct person_struct { char *name; } person; changeStructName(person * name1) { name1->name = "Robert"; } changeCharName(char * name2) { name2 = "Jose"; } int main() { person * name1; ...

Similar syntax causes strange, repeated compile errors when building PHP from source on Windows

I am trying to build PHP from source per these instructions. The configure works really well, but when I get to the nmake part, things fall apart. I have no idea why I am getting errors about struct's, the lines referenced are functions! I have put the problematic zend_interfaces.c here. Zend\zend_interfaces.c(320) : error C2332: 'str...

Is this C function written in poor form?

char byte_to_ascii(char value_to_convert, volatile char *converted_value) { if (value_to_convert < 10) { return (value_to_convert + 48); } else { char a = value_to_convert / 10; double x = fmod((double)value_to_convert, 10.0); char b = (char)x; a = a + 48; b = b + 48; *converted_value = a; *(converted_value+1) = b; r...

Extracting timings from a multidimensional array and writing to a file in c

Hello, I'm having trouble extracting the timings from a .srt (subtitle) file and writing it to another file called output.srt. When i run the following i get some funky stuff written onto the output file. // where hr=hours,mn=minutes,sc=seconds,ms=mili seconds #include <stdio.h> #define LINES 50 #define CHARAC 80 int main(void){ FI...