c

calling fdopen: Bad file descriptor

I'm getting the following error when trying to compile my program: calling fdopen: Bad file descriptor I've read this might be a problem related to including a precompiled header in one of my header files. The file which is causing the error includes the stdio.h header in it so I have access to the FILE type. If I remove this, the er...

Filling in a queue with C

correction it works now thanks everyone. Okay so now I have updated my main file to main.c #include "queue.h" int main(){ int i; int* dataPtr; int number; QUEUE* numbers; numbers = createQueue (); printf("Please enter the 10 numbers you want to know the sum and average of.\n"); for (i = 0; i < 10; i++){ ...

Graphics Gems IV. Binary Image Thinning Using Neigborhood Maps

What's mean this expression in algorithm? p = ((p<<1)&0666) | ((q<<3)&0110) | (Image->scanLine(y+1)[x+1] != 0); Algorithm "Binary Image Thinning Using Neigborhood Maps" in a book "Graphics Gems IV": static int masks[] = {0200, 0002, 0040, 0010}; uchar delete_[512] = { 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,1,0,0,1,1, ...

64 bit negative integers in two's complement form

Hi. I was reading the source of GNU PDF library, particularly their implementation of 64 bit integers. They have defined 64 bit integers as structs of two 32 bit integers - the higher order int is signed and lower order int is unsigned. Here's the relevant code from the header file: /*Definition of internal structure of the pdf_i64_t ...

How to get path of file dragged into Win32 app and delete it?

I have a program and when they drop files into it I want it to get the path show a messagebox "of the path" then delete it. Can anyone shed some light on how to do this? ...

Error with my program

Okay I have the queue program that I have been working on and I finally figured most of it out. The problem I am having now is that everytime I enter numbers into the keyboard and then access them I get the same number. if I enter 5 ones when it goes to add them together it says the answer is 37 which is not right. here is my code again:...

LibTomCrypt and LibTomMath—development status?

LibTomCrypt in the past has seemed like a very viable and useful option for encryption. And the associated LibTomMath could be a useful math library. But lately, I can't see any development on it and it's ambiguous as to what is the "current" web site for it. E.g.: http://libtomcrypt.com/ which points to http://libtom.org/ old page h...

floating point - absolute value - inline assembly - edited new code

I wrote a function named absD that i want to return the absolute value of its argument.. I am using GCC inline assembly with cygwin.. I dont see why its not working. i m loading into memory. then into st(0) where i am using fabs - absolute value. Do i have to allocate memory? I am trying to learn assembly with C here so please be nice....

Release all open files and directories at exit forcefully in C

I want to release all open files and directories forecefully my program has opened during its execution. I want to do this because I have a very big program and it opens many files and directories which I am not able to keep track. Is there any way to do it? means I want to retrieve a list of all open files and directories and close them...

Using extern to include files in C or C++

How this works in C or C++? extern "C" { #include <unistd.h> #include <fd_config.h> #include <ut_trace.h> #include <sys/stat.h> #include <sys/types.h> } ...

How to make window non transparent?

Dear All I want to make parent window as non transparent with RGB value as (99,99,99)? Previously my window was transparent but now i have requirement to make window as non transparent. Mentioned below are the function related to my parent window: ATOM MyRegisterClass(HINSTANCE hInstance) { LogEntry(L"Entered in myRegisterClass Fu...

System call return value in C

Hi,  I am using system function in C code to invoke cp command. I want to know whether it got executed successfully or not? ...

create numbered files in C

I need to create files that have the same name, but with a number attached to the end of the filename to indicate that it was the nth file made. So in a for loop, I basically want to do this: char *filename = "file"; strcat(filename, i); // put the number i at the end of the filename Clearly that isn't the way to do it, but any ideas ...

Obtain MAC Address of Devices in range of router

Is it possible for a router to obtain the MAC address of nearby devices that have not connected to it? I want to write an app that notifies me somehow (email or something) when a specific MAC address comes within range of a router that I have (the app is much more specific than that so I cannot use prebuilt tools but if they are open sou...

Why memory allocation on heap is MUCH slower than on stack?

I have been told this many times. But I don't know WHY...What extra cost is involved when allocating memory from heap? Is it hardware related? Is it realted to CPU cycles? So many guesses but no exact answers...Could someone give me some elaboration? Just as "unwind" said, the Heap data structure is more complicated than Stack. And In ...

problem mixing c and c++

hi everyone i need to build a c++ project that exports functions to c project this is my c++ class : ** MyCppClass.h ** class MyCppClass { public: static void MyCppMethod() } ** MyCppClass.cpp ** void MyCppClass::MyCppMethod(){} *now i need to create an interface for the Method MyCppMethod (static). i did that : ** MyExport.h** ...

Is there a lightweight multipart/form-data parser in C or C++?

I'm looking at integrating multipart form-data parsing in a web server module so that I can relieve backend web applications (often written in dynamic languages) from parsing the multipart data themselves. The multipart grammar (RFC 2046) looks non-trivial and if I implement it by hand a lot of things can go wrong. Is there already a goo...

Reading the last 50 characters of a file with fseek()

I'm trying to read the last 50 characters in a file by doing this: FILE* fptIn; char sLine[51]; if ((fptIn = fopen("input.txt", "rb")) == NULL) { printf("Coudln't access input.txt.\n"); exit(0); } if (fseek(fptIn, 50, SEEK_END) != 0) { perror("Failed"); fclose(fptIn); exit(0); } fgets(sLine, 50, fptIn); printf("%s", ...

Static keyword in function parameter

I've just found this function definition in some embedded code: float round_float_to_4(static float inputval); I'm familiar with other uses for static (global variables, functions and local variables), but this is the first time I see it as specifier for function parameter. I assume that this forces compiler to use fixed memory locati...

Unexpected strtok() behaviour

I'm trying to count the number of words in a file with strtok(). /* * code.c * * WHAT * Use strtok() to count the number of words in a file. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #define STRMAX 128 int main() { /* Declarations */ FILE* fptr; int iCntr = 0; char sLine[STRMAX]; char* ...