c

Reading, Comparing and taking input non ASCII charachter(i.e Bangla and other indic script) array in C

Can I work with Begali charachters(non ASCII) in C? ...

Random Access Function question in C

I am trying to learn C and the book I am using (Apress' 'Learn C') has a chapter that is terribly confusing on Random Access functions. The following code is confusing me: int GetNumberOfDinos( void ) { FILE *fp; long fileLength; if ( (fp = fopen( kDinoFileName, "r" )) == NULL ) DoError( "Couldn't open fi...

How to programmatically schedule a task to run when shutting down Windows?

This is almost the same as http://stackoverflow.com/questions/101647/how-to-schedule-a-task-to-run-when-shutting-down-windows, except I need to do it programmatically. Also, I need the guarantee that when the script is run, no application can cancel the shutdown anymore. Is this possible? Thanks. Update, with a little context: My comp...

User input custom control (text editor)

I am developing a CAD like application. This application is cross platform in the sense that I have a main window which is native to the platform it is running on (Linux, Windows and Apple). Within this window I have an OpenGL context and there I do all my rendering. The application in question does not really rely on common controls (ra...

Determining type of variable during run-time in C

I have several variables of type char (array), int, and double. Is there a way to identify what type they are during run-time? For example, I'm looking for something like: int dummyInt = 5; double dummyDouble = 5.0; dummyInt == int ? printf("yes, it's of int type\n") : printf("no, it's not of int type\n"); dummyDouble ...

Which winapi function will allow me to change logged in user's password?

I'm looking for a winapi function that will allow me to change current logged in user's password. In my case, I know current password of logged in user. I use Windows 7 Ultimate. Thanks. Background The background will look weird, but I'm going to describe it for clarification. My personal home PC is used by several users (dad, sister,...

Calculating sliding averages

I'm not even sure what sliding average is, but someone told me it would help with something I'm working on. I have a table of random values -- table[n] = random(100) / 100 I need to populate table2 with their sliding averages. I think this is the terminology. Let me know if it doesn't make sense. ...

enumerating each ip assigned to network interfaces

I think there is no way to enumerate each network interface on my system and their assigned IP using just sockets, is this correct? I mean, in linux this could be: eth0: 192.168.1.5 wlan0: 192.168.0.5 lo: 127.0.0.1 I dont care interface names, just the IPs assigned. I recall to have done this in the past in Windows, using winapi (tho...

Xlib: XGetWindowAttributes always returns 1x1 ?!

I'd like to have width and height of the currently focussed window. The selection of the window works like a charm whereas the height and width are always returning 1. #include <X11/Xlib.h> #include <stdio.h> int main(int argc, char *argv[]) { Display *display; Window focus; XWindowAttributes attr; int revert; disp...

fopen fails is file opened in visual studio

I have the following code : FILE *fp = fopen( srcFile.filename.c_str(), "rt" ); srcFile happens to be the solution's main.cpp file, and thus is opened in the solution. fopen returns NULL most of the time (but not when I step into it, which is weird). However, when I close main.cpp in Visual Studio, the code works. Even when the fil...

Makefile conditional include

I'm trying to write an application that needs either ALSA or OSS headers. Basically, I want to pass a define to the compiler if /etc/oss.conf does not exist, since that probably means the soundcard.h header doesn't exist (feel free to correct me on that one, I'm still new to working with OSS). Per the OSS documentation, you would use the...

(c/c++) trying to force EOF from parent process sending input to child process

i have a very simple c/c++ program that forks a child process to execute another program, and then sends some data to that child program, and waits for the response. the child program reads from stdin and waits for EOF before it continues. my problem is, the child program receives the initial input from the pipe writing, but it never s...

C: Each child process reads alternate lines

I'm training a typical map-reduce architecture (in O.S. classes) and I'm free to decide how the master process will tell its N child processes to parse a log. So, I'm kind of stuck in these two possibilities: count the number of rows and give X rows for each map OR each map reads the line of its ID and the next line to read= current_on...

mingw. how to use static and dynamic linking both

lets make the simpliest application: result: ok. it works. lets add some SDL with default dynamic linking here! result: works great. at stdout.txt we can see "puchuu" lets change our makefile a little. just group 2 object files to the static lib: result: Who is to blame? Me or mingw developers? is it clear to...

Problem with a feature in a shell program.

This Program works fine with exception for one aspect of smarthistory(). I cannot figure out why when I enter a command number from the smarthistory array why it doesn't execute. After entering the command to execute from the list nothing happens not even the printf statement right after. I am using the gcc compiler. const int MAX_HI...

How do i store a set of values in an array without using square brackets, but by using pointers

In C programming, how can a store a set of values entered by the user into an array using only pointers and no square brackets? ...

Counting bits in a int - why does this code work?

I was trying to learn more about bits, and I came across this example. How does this code work to count the bits? (My C is very rusty, by the way). unsigned int v; // count the number of bits set in v unsigned int c; // c accumulates the total bits set in v for (c = 0; v; v >>= 1) { c += v & 1; } ...

Piping output of C program to file (bash)

I'm just trying my hand in bash, so I wrote a simple program in C to count the number of characters in a file. This is my C program: #include <stdio.h> int main() { int i, nc; nc = 0; i = getchar(); while (i!=EOF){ nc = nc + 1; i = getchar(); } printf("%d\n",nc); return 0; } This is the bash command I'm using ...

Confusion about pointers and multidimensional arrays.

If the following is possible: MyFunction(int *array, int size) { for(int i=0 ; i<size ; i++) { printf(“%d”, array[i]); } } main() { int array[6] = {0, 1, 2, 3, 4, 5}; MyFunction(array, 6); } Why the following is not? MyFunction(int **array, int row, int col) { for(int i=0 ; i<row ; i++) { ...

Checking for the existence of externally defined identifiers in C

I ran into this problem while developing in Objective-C for iOS, but this should apply to any C/C++/Objective-C code using the Mac OS X/iOS linker. The solution is covered by another question, but I'm interested in the why. Let's say I'm using a linking to a library which defines a constant. In a header file there is a declaration like ...