c

How to properly make my makefile to compile and run?

The question is probably not the best one to describe my issue but I couldn't think of a better one. My makefile goes like this: PROGRAM_NAME = prog OBJECT_FILES = $(PROGRAM_NAME).o CFLAGS = -O2 -Wall -g $(PROGRAM_NAME) : $(OBJECT_FILES) gcc $(CFLAGS) -o $@ $(OBJECT_FILES) $(PROGRAM_NAME).o : $(PROGRAM_NAME).c data.h gcc $(CF...

Are there any standard input/ouput macros for read/write system calls in C?

All my searches returned nothing and I find it odd that there aren't any macros to use as file descriptors for read/write system calls for standard input and output instead of a 0 (stdout) and a 1 (stdin). Am I missing them or they really don't exist? ...

Analyze SSL certificate programatically or via commandline

Hey there, I'ld like to analyze the certificate of a given url and get some details of it. Do you know any ways to do this? A command-line tool can be something like downloadSSLCert https://my.funny.url/ > certFile and then analyzing it for e.g. the fingerprint of the cert. It can be a command line utility, a c/c++/objective-c or java c...

How to get a thread to continue after write() has written less bytes than requested?

I'm using the following code to write data through a named pipe from one application to another. The thread where the writing is taken place should never be exited. But if r_write() returns less than it should, the thread/program stops for some reason. How can I make the thread continue once write has returned less than it should? ssize...

How to guarantee read() actually sends 100% of data sent by write() through named pipes

I've got the following two programs, one acting as a reader and the other as a writer. The writer seems to only send about 3/4 of the data correctly to be read by the reader. Is there any way to guarantee that all the data is being sent? I think I've got it set up so that it reads and writes reliably, but it still seems to miss 1/4 of th...

Robust Face Detection in C/C++?

I'm looking for a robust face detection algorithm/library, preferably in C (C++ is okay too; other languages I can port if necessary). I've used OpenCV's implementation in the past, but I don't think it's invariant to rotation. Doesn't need to be real-time, but it shouldn't be horrendously slow either (maybe one or two seconds per photo ...

Determining whether explorer.exe runs as a windows shell?

I need to make sure that explorer.exe runs as a system shell. What I need to do is: Overwrite the current shell (Winlogon\Shell) with explorer.exe Run explorer.exe (as shell) Overwrite the current shell with my own shell. Between the last two steps is a race: If I overwrite the current shell with my own shell too quickly, only "My ...

Obtaining Own External IP Address in POSIX C

I'm looking to obtain my own IP Address in order to publish that information in to a Peer-to-Peer network. In POSIX/C we have getaddrinfo(NULL, ...), but this always seems to returns INADDR_ANY or INADDR_LOOPBACK, which is useless to me. Any suggestions? ...

C++ array[index] vs index[array]

Possible Duplicate: In C arrays why is this true? a[5] == 5[a] Is the possibility of both array[index] and index[array] a compiler feature or a language feature. How is the second one possible? ...

Using floats with sprintf() in embedded C

Guys, I want to know if float variables can be used in sprintf() function. Like, if we write: sprintf(str,"adc_read = %d \n",adc_read); where adc_read is an integer variable, it will store the string "adc_read = 1023 \n" in str (assuming that adc_read = 1023) How can I use a float variable in place of integer? ...

Does C have __func__ functionality for names of the arguments of a function?

Does the "C" standard support something similar to __func__ for the function arguments' names? ...

What does this C error about structures mean?

Hey everyone! Could someone please help me understand this error in C for structures? This is my code: struct Orientation { char facing; char sensor; char mazeDir; }; struct Orientation O[16]; O[0] = {'N', 'F', 'N'}; O[1] = {'N', 'B', 'S'}; O[2] = {'N', 'R', 'E'}; O[3] = {'N', 'L', 'W'}; O[4] = {'S', 'F', 'S'}; O[5] = {'S'...

Why can't I use fopen?

In the mold of a previous question I asked about the so-called safe library deprecations, I find myself similarly bemused as to why fopen() should be deprecated. The function takes two C strings, and returns a FILE* ptr, or NULL on failure. Where are the thread-safety problems / string overrun problems? Or is it something else? Thanks ...

Inspecting C pipelines passing through a program -- border cases

Hi there, I'm receiving from socket A and writing that to socket B on the fly (like a proxy server might). I would like to inspect and possibly modify data passing through. My question is how to handle border cases, ie where the regular expression I'm searching for would match between two successive socket A read and socket B write iter...

Test cases in C for WIFSIGNALED, WIFSTOPPED, WIFCONTINUED

I'm playing with waitpid() and signal() and I'm looking for reliable test cases for returning WIFSIGNALED(status) = WIFSTOPPED(status) = WIFCONTINUED (status) = true but can't find any... Care to tell me how can I make sure those return true so I can debug my code? Also, a few hints about what signals should I catch with signal() to te...

Style question about existing piece of code (C/C++)

I just hope the following doesn't seem to you like redundant jabber :) Anyway, there is that: for (p = fmt; *p; p++) { if (*p != '%') { putchar(*p); continue; } switch (*++p) { /* Some cases here */ ... } } And I wondered why the writer (Kernighan / Ritchie) used the continue in the if ...

Using strsep() with dynamic array of strings in C

I have the following code: #include <string.h> int main(void) { char *buffer = NULL, **words = NULL, *aPtr = NULL, *sPtr; int count = 0; buffer = strdup("The quick brown fox jumps over the lazy dog"); sPtr = buffer; do { aPtr = strsep(&sPtr, " "); words[count++] = ... // missing code } while(aPtr); ...

Wait for certain website to be accessed

My objective is to have an event that is triggered when a website is accessed. Now, maybe through the window title, or the text in the window. Or maybe even reading a URL. As of now I am aware of FindWindow (class,title); However all attempts to put this line of code into a loop and it's exit condition being when the window appears hav...

file size c is different than the size data string's size

I have a file I'm writing to and then changing the size of it to the size of text written to it something like: FILE * file... I get all the data from the file and change the file's size to the data's size but it differs. The string's size is smaller then the filelength and it cuts it and loses data. What might be the problem? while(...

Creating Makefile in Windows

I have a folder named 'X'. In X I have two subfolders named 'src' and 'include'. The 'src' folder contains a C file 'main.c', and the 'include' folder contains a file 'main.h'. I want to write a makefile to build these files(from folder X) in windows command prompt. I have tried a lot but with no effect. First of all I need the make fi...