c

How do you create, compile and use static and dynamic libraries in linux-like systems?

Hello, this is my main question: How do you create, compile and use static and dynamic libraries in linux-like systems? What is the difference between them? Are there any good free tutorials explaining this stuff for a total idiota like me. I've only done c# programming before. I know a little C, C++ and Objective-C. I'm developing fo...

How to get involved in C standardization process?

Hello, Lately I've been getting interest in C standardization. I want to participate in development of C1X. I want to put forward my ideas (irrespective of they being accepted/rejected). I want to know the procedure. WG14 documents shows various documents sorted by mailing list. Where can I join one such mailing list? How to submit a p...

Is it possible to move backwards through a getopt_long argument list?

I would like to delegate to one of several possible lists of arguments based on whether particular arguments are present, along the lines of: ./test --do-thing-1 --option-A=7 --common-option --option-B=2 # options C and D not valid ./test --do-thing-2 --option-C=9 --common-option --option-D=1 # options A and B not valid And the best w...

Can't a function return a string without pointers?

I am having a strange problem while returning a string. it says can not convert int to const char* #include<stdio.h> #include<conio.h> #include <string.h> /*The above program shows that you can not return a string from a function normally*/ char check(char str[]); void main(void) { char str[30],str2[30]; printf("Enter a sentence...

Appending a data to file in c

I require to add a string before 45byte in an existing file. I tried using fseek as bellow. int main() { FILE *fp; char str[] = "test"; fp = fopen(FILEPATH,"a"); fseek(fp,-45, SEEK_END); fprintf(fp,"%s",str); fclose(fp); return(0); } I expected that this code will add "test" in before 45 char from EOF...

Arguments in a function prototype

Hi. My question is: when i write a function prototype in C like this: void foo(int *vector); It's the same thing to do: void foo(int vector[MAX_LENGTH]); To the function, is passed always as a pointer? The code it's the same? Thanks in advance. ...

Packet sniffing in c under window OS

I want to sniff network packets without wincap library, kindly give me some hints or direction so that I can make it possible. ...

linux du command source code

Where I can find the source code for du and other Linux utilities? ...

How to get the Char a const * TCHAR pointer points to

Hey, I've got some problems with a pointer void getPartOfString(const TCHAR * wholeString) { const TCHAR * pPointer = NULL; pPointer = _tcsstr(wholeString, searchedString); //searching for a special string in string pPointer += _tcslen(searchedString); //set pointer to the beginning of the string wanted //here I want t...

So setsockopt for timeouts on AF_UNIX (AF_LOCAL) sockets... undocumented/don't work... options/alternatives?

I'm running Fedora 13 if that matters. I looked up man pages on unix(7), setsockopt, and send/recv. Reading the man pages seems to more or less tell me that not all options are guaranteed to do ANYTHING... and apparently only a few that do/don't work are actually documented. In particular... I wanted to see if timeouts were possible. ...

Porting Assembly to C/C++?

Hi, I would like to have this x86 ASM code ported to C or C++, as I don't understand ASM =) Searching Google it seams Relogix and IDA Pro can do it. But I don't suppose they are cheap, given I only have this one source. Understanding the math or the algorithm how it works would be just as good, as I am going to use OpenGL anyway. Are...

Changing C variables from python?

I have an embedded python interpreter in my program. I'd like to export a module with values defined in my program and be able to change them from a python script. e.g. in c: int x = 1; in python: import embedded embedded.x = 2 in c: printf("%d",x); output: 2 Is this possible or do I have to export functions to change anything i...

what is the return type of typeof?

Hi, I want to provide the type of an element as parameter to an initialization of an array of pointers to element of an unknown types something like void* init(type t) void* array = malloc(sizeof_type(t)*10)); return array; } and later call for example init(typeof(int)) But I was not able to figure what is the return type ...

c language. Return type of a function

?? fun() { int a[3]={3,3,4}; return &a; } what could be the compatible return type. Here the pointer is pointing to the array of 3 integers not just the pointer which points to integer array. Aim is to return a pointer to array of 3 integers. ...

What does this function do?

I am reading a program which contains the following function, which is int f(int n) { int c; for (c=0;n!=0;++c) n=n&(n-1); return c; } I don't quite understand what does this function intend to do? ...

Make Xcode tell the compiler to not link to any library including the standard library?

Well, the title says it all: How can I make Xcode tell the compiler not to link? I am making a library which may not link to anything. Where can I set in the target's properties that it must not link to the standard library, as I can choose static or dynamic only, there is no not option. Can you help me, please? Thanks. ...

C: MSVC2008 Malloc and crashing program

This question might be remedial but I am having a lot of trouble with malloc. Why does my progrm crash upon freeing memory? #include <stdlib.h> #include <malloc.h> int main(int argc, char *argv[]) { int *arr[10]; void *mem = malloc( 10 * sizeof(int) ); int i; for(i=0;i<=9;i++) { arr[i] = (int*) mem + i*sizeof(int...

Field alignment of a struct in C/C++

Are the members of a structure packed in C/C++? (by packed I mean that they are compact and among the fields there isn't a memory spaces) ...

Libjpeg: setting DCT coefficients

Hi, I need to modify a DCT Coefficient for an application of steganography in C language. Is there any easy way to do it? Thanks a lot. ...

What is newline character -- '\n'

Hi, This is a very basic concept, but something I have never been able to articulate that well. and I would like to try to spell it and see where I go wrong. If I have to, how would I define a "newline character". say if I create a new file in unix(or windows), then does the file store the "end of line" information by inserting a speci...