c

Socket 'No route to host' error.

I have a connection which is behind a restrictive firewall which only allows HTTP(S) access through a proxy (10.10.1.100:9401). The IP address I get is dynamic and the subnet mask is 255.255.255.255 (I know, weird!). I tried to write a simple Python socket program to connect to the proxy in order to send some HTTP requests: import sock...

Show Windows Users Dialog

Hello Folks, How do you (programatically) show the windows local users/groups dialog? In Vista it's usually under Control Panel - Administrative Tools - Computer Management - Local Users and Groups. Similar kind of dialog with the same functionalities (add/remove users/groups) is also acceptable, as long as supported by Windows Xp and a...

simple c malloc

While there are lots of different sophisticated implementations of malloc / free for C/C++, I'm looking for a really simple and (especially) small one that works on a fixed-size buffer and supports realloc. Thread-safety etc. are not needed and my objects are small and do not vary much in size. Is there any implementation that you could ...

Trouble with characters in C

Hi Why does this not compile? Cant see the error #include <stdio.h> #include <string.h> #include <stdlib.h> int main(void) { char *c; FILE *f = fopen("file.txt", "r"); if(f == NULL) { printf("Could not open file"); } while((c = fgetc(f)) != EOF) { if(strcmp(c, " ") == 0) { printf(" ");...

How can I determine to which C standard is this code compliant?

In a C lab this uber simple code appears: #include <stdio.h> int suma (int a, int b) { return a+b; } int mult (int a, int b) { return a*b; } int main(void) { int a,b; printf ("Operando 1: "); scanf("%d",&a); printf("Operando 2: "); scanf("%d",&b); printf("%d+%d=%d\n",a,b...

what is causing this segmentation fault? example from book

hi - I am going through a book and I tried running this example but I receive a segmentation fault - gdb says it's when it sets argv[0] = filename; this code is copied/pasted straight from book's downloadable code samples. #include <unistd.h> int main() { char filename[] = "/bin/sh\x00"; char **argv, **envp; // arrays that contain...

about malloc() and free() in C

I have the following C-code: #include<stdio.h> #include<stdlib.h> typedef struct node { int a; }node; int main() { node * n; printf("\n%d\n",n->a); n = (node *) malloc ( sizeof( node )); printf("\n%d\n",n->a); n->a = 6; printf("\n%d\n",n->a); free(n); printf("\n%d\n",n->a); n->a = 4; pri...

Converter and compresser between ASCII and Binary

Hi I am trying to make a very easy converter/compressor; the program should take a file with 4 different types of ASCII characters and writ it out as binary to a file. The program should also read the binary file and convert it to ASCII and print it out on the screen. Under is my code, I can’t really get the char/cstring. What types of ...

C Programming Exercises

Possible Duplicate: Where can I find C coding exercises to practice? I am learning c programming language and i need some exercises resources to practice from. ...

How can I know the current state of signals

Hi, Is there a way in C to know the following information about signals: Is certain signal is blocked now? Are we inside a signal handling function chanin (i.e, was the current code called from function which was called as signal handler for certain signal)? If so, can I know what is the current signal? Thanks ...

Using Visual Studio 2010, how do I provide input to a Visual C++ Win32 Console Application?

I am using Visual Studio 2010 Pro for simple C programming, I would like to know how I can provide input to the program without having to manually do so. The enviroment I am used to working is your standard commandline Unix enviroment. Once I compile a C file call "inputsInts" it becomes "a.out" and to test input I would type: The easy ...

Resource recommendations for Windows performance tuning (realtime).

Hi all, Any recommendations out there for Windows application tuning resources (books web sites etc.)? I have a C++ console application that needs to feed a hardware device with a considerable amount of data at a fairly high rate. (buffer is 32K in size and gets consumed at ~800k bytes per second) It will stream data without under run...

3d Accelerometer calculate the orientation

Hi, I have accelerometer values for the 3 axis(usually when there is only gravity contains data between -1.0 and 1.0 ): float Rx; float Ry; float Rz; I make soma calculations, then I get the angles for each axis. float R = sqrt(pow(Rx,2)+pow(Ry,2)+pow(Rz,2)); float Arx = acos(Rx/R)*180/M_PI; float Ary = acos(Ry/R)*180/M...

Translate drive letter to full path for CD burner.

In the following code, I am trying to get a folder location from the user. However, when I selected E:\ in the folder browser, szAbsolutePath doesn't give me the path for the CD burner temporary folder. This prevents me from saving to this location. However, if I choose something like E:\folder1\, I get the full path and can write out fi...

Question on equating arrays in C

Suppose I have two int arrays x and y, and both of them have length 3. x={0,1,2}. Is there any one step way to assign the values of x to y. When I do y=x, and try to print the values of y, the code does not compile. I dont want to go through the pain of writing a for loop, and write y[i]=x[i] ...

Is it possible to execute code from the stack in standard C?

The following code doesn't work as intended but hopefully illustrates my attempt: long foo (int a, int b) { return a + b; } void call_foo_from_stack (void) { /* reserve space on the stack to store foo's code */ char code[sizeof(*foo)]; /* have a pointer to the beginning of the code */ long (*fooptr)(int, int) = (long (*)(int...

Erlang source code guide

I am interested in delving into Erlang's C source code and try to understand (at least at a moderate level) what is going on under the hood. Where can I find info on the design and structure of the code? ...

Example of Something Which Is, and Is Not, a Constant Expression in C?

I'm a tad confused between what is and is not a Constant Expression in C, even after much Googleing. Could you provide an example of something which is, and which is not, a Constant Expression in C? ...

What posix_fadvise() args for sequential file write?

I am working on an application which does sequentially write a large file (and does not read at all), and I would like to use posix_fadvise() to optimize the filesystem behavior. The function description in the manpage suggests that the most appropriate strategy would be POSIX_FADV_SEQUENTIAL. However, the Linux implementation descripti...

C Programming Tutorial by Problem Set

I'm currently brushing up on C programming and I'm looking for an online site that teaches the language through a series of programming problems. These problems would gradually increase in complexity and focus on introducing one or two new concepts of the language as the user/student learns more. I'm familiar with the UVa Online Jud...