c

How does this work?

In applications like Adobe Illustrator, they have a way to simplify a path. I'm not sure how this works exactly. Given a path with points which have 2 bezier handles each (for cubic bezier), how could I go about simplifying the path? Thanks ...

programming style guide for C

It has been a while since I've written C, and I never really did any formatting when I did it since it was all toy work and inconsequential. For open source C projects, what would be the best (being the most agreed upon and utilized) style guide (Formatting and convention wise) to follow? ...

PATH HTU DISCOVERY in linux

can any one help me to write a c code to find out PMTU of intermediate routers, which allow ICMP packets to pass ... ...

the following is giving an error, please tell what is wrong with it.

#include<stdio.h> main( ) { int num[ ] = {24, 34, 12, 44, 56, 17}; dislpay(&num[0],6); } display ( int *j, int n ) { int i ; for ( i = 0 ; i <= n - 1 ; i++ ) { printf ( "\nelement = %d", *j ) ; j++ ; /* increment pointer to point to next element */ } } The language is c, windows vista using visual c++ 2005 express. ...

"Incompatible pointer type" compiler warning for 4th argument of qsort

I'm trying to use the standard library's qsort to sort an array of wide characters: wchar_t a = L'a'; wchar_t a1 = L'ä'; wchar_t b = L'z'; wchar_t chararray[] = {b, a, a1}; length = wcslen(chararray); qsort(chararray, length, sizeof(wchar_t), wcscoll); Now I think the functions involved have these prototypes: int wcscoll(const wch...

Why is it not OK to pass `char **` to a function that takes a `const char **` in C?

Possible Duplicate: Why cant I convert char* to a const char const* in C? I am curious, why can't I pass a char ** to const char ** function? Where as it is OK to pass char * to a const char * function it seems not to be OK to do it with double pointers. I thought it was always ok to add constness (but not ok to drop constness...

long long vs int multiplication

Given the following snippet: #include <stdio.h> typedef signed long long int64; typedef signed int int32; typedef signed char int8; int main() { printf("%i\n", sizeof(int8)); printf("%i\n", sizeof(int32)); printf("%i\n", sizeof(int64)); int8 a = 100; int8 b = 100; int32 c = a * b; printf("%i\n", c); i...

logical AND operator

I am little confused with logical AND operator. I have these 2 lines of code. Here num and j are both ints. I have a situation where both the conditions are satisfied, but I don't know why it's not printing the value of j. Can anybody point out the mistakes? Thanks in advance. if(k==1 && num%j==0) printf("%d",j); ...

Printf with Double Formatting Question

I've got the following printf statement: printf("val=%-4.2lf", val); However, val is never padded with spaces so the space taken up by val is different if there are 3 or 4 digits before the decimal. Shouldn't the 4 in the format specifier guarantee that there are at least 4 spaces? Sorry for the newb question but it's been frustratin...

Converting C Macros to Actionscript 3

I am trying to convert a macro in C to something that would work similarly in Actionscript. The C macro takes a string, and using ## checks the type against other macros to check that the item's property is of the right type. To clarify, the C: ... #define STACK_NUM 52 ... #define CHECK_TYPE(i, t) \ ( ((i).type == t##_NUM) ) ...

Detect desktop environment in Linux programmatically in C

I am trying to detect whether I am running on a Gnome or KDE desktop environment. I know I can check via a ps -aux and grepping either gnome or KDE but that's not good: 1) what if I am on a gnome desktop but I have the KDE libs loaded? 2) I need to do it from code without using system() or popen() or other fork/exec combination. I can ...

a = -2147483648 - a; compiler optimization

Hello, I'm trying to learn how to reverse engineer software and all the tricks to understand how the code looks like before the compiler optimizations. I found something like this several times: if (a < 0) a = -2147483648 - a; I originally thought it was an abs(): a underflows so you get the positive value. But since a is n...

Reverse a c-type string.

Here is my code: void reverseStr(char *str) { if (str == NULL) return; int i=0, j=strlen(str) -1; while(i<j) { char temp = str[j]; //i think this is the cause of the problem str[j] = str[i]; str[i] = temp; i++; j--; } } So here is where it is called: int main() { ...

C: Handling HTTP requests and responses

What is the best C library for sending HTTP requests and processing the responses? ...

Runtime error when calling function

I have a program that calls a function in a dynamically-linked library. All of the function calls work fine, except one. double *frameData = NULL; int frameDataSize = 0; g_BeamGage_GetSingleFrame(BEAMGAGE_ID, &frameData, &frameDataSize); //error here When BeamGage_GetSingleFrame is called when debugging my program, I get a runtime err...

Substring search interview question

char* func( char* a, const char* b ) { while( *a ) { char *s = a, *t = b; while( (*s++ == *t++) && *s && *t ); if( *t == 0 ) return a; a++; } return 0; } The above code was written to search for the first instance of string "b" inside of string "a." Is there any probl...

Best practice for reading csv (with variable number of lines) into data structures

Hey guys, I'm writing a small program to read in a csv with a variable number of lines and have a question about best practices: Is the best way to create storage for the data on each line to make an array that holds the data structures of the csv (one per each line of csv)? Size allocated to the array could be set to a large number (f...

Is there a way to access individual bits with a union?

I am writing a C program. I want a variable that I can access as a char but I can also access the specific bits of. I was thinking I could use a union like this... typedef union { unsigned char status; bit bits[8]; }DeviceStatus; but the compiler doesn't like this. Apparently you can't use bits in a structure. So what can I ...

C: JSON processor

Possible Duplicate: Parsing JSON using C? What's is the best C library for processing JSON? There are several listed at http://www.json.org/. ...

Simplifying a cubic bezier path?

I'm trying to achieve something close to what Adobe Illustrator does with the brush tool. It correctly analyzes and simplifies the path, including its bezier handles. I implemented the Ramer–Douglas–Peucker_algorithm however, it wound up not really being what I needed. It works very well for line segments, but doesn't factor in bezier ha...