c

C toLowerCase Function won't work - Access violation

Hi, I have a simple function which takes an array of characters as an argument, and converts all the characters to lower case. However, I get a weird access violation error. Here's the code: void toLower(char *rec) { int i=0; while (rec[i]!='\0') { if (rec[i]>='A' && rec[i]<='Z') rec[i]='a'+rec[i]-'A'; //this is ...

Trouble compiling C/C++ project in NetBeans 6.8 with MinGW on Windows

I am learning C and because VC++ 2008 doesn't support C99 features I have just installed NetBeans and configure it to work with MinGW. I can compile single file project ( main.c) and use debugger but when I add new file to project I get error "undefined reference to ... function(code) in that file..". Obviously MinGW does't link my fil...

What is faster: multiple `send`s or using buffering?

I'm playing around with sockets in C/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket. My ideas: use a send call for every header. Pros: No memory allocation needed. Cons: many send calls -- probably error prone; error management should be rather complicated use a buffer....

Why gcc4 warn and how to avoid it

I have a function declared as: void event_add_card (EventAddr addr, EventType type, unsigned char card); and union typedef union EventData { float money; /**< money info */ unsigned char card; /**< new card */ } EventData; When i compile following code: EventData data = {}; event_add_card (0,0, d...

C/C++ in Android?

Is it possible to use C/C++ code in Android? And how easy is it? ...

Is there any free OCaml to C translator?

So I have nice OCaml code (50000 lines). I want to port it to C. So Is there any free OCaml to C translator? ...

GCC/X86, Problems with relative jumps

I'm trying to do a relative jump in x86 assembly, however I can not get it to work. It seems that for some reason my jump keeps getting rewritten as an absolute jump or something. A simple example program for what I'm trying to do is this: .global main main: jmp 0x4 ret Since the jmp instruction is 4 bytes long and a relativ...

write system call to file desciptor ZERO

int main ( ) { char C[] = "Hello World"; write(0,C,sizeof(C)); return 0; } In the above program, I am writing to File descriptor ZERO which I suppose by default is STDIN.. Then why I am I getting output at STDOUT? shadyabhi@shadyabhi-desktop:~$ ./a.out Hello Worldshadyabhi@shadyabhi-desktop:~$ ...

An error saying unidentifed function "push", "pop", and"display" occurs, what should i add to fix it?

#include<stdio.h> #include<iostream.h> #include<conio.h> #include<stdlib.h>(TOP) #include<fstream.h> #define MAX 5 int top = -1; int stack_arr[MAX]; main() { int choice; while(1) { printf("1.Push\n"); printf("2.Pop\n"); printf("3.Display\n"); printf("4.Quit\n"); printf("Enter your choice : "); scanf("%d",&choice); switch(choice) { ca...

Is there any free Python to C translator?

Is there any free Python to C translator? for example capable to translate such lib as lib for Fast content-aware image resizing (which already depends on some C libs) to C files? ...

Visual studio 2010 exiting after program ends

Hi, I'm trying out Visual studio 2010 by compiling a C program. After it displays the solution in the "DOS" command window, the window is immediately closed. In Visual studio 2008, one gets the message press any key to continue and pressing a key closes the command prompt window. How do I set this behavior in 2010? Thanks a lot... ...

Big numbers in C

I need help working with very big numbers. According to Windows calc, the exponent 174^55 = 1.6990597648061509725749329578093e+123. How would I store this using C (c99 standard). int main(){ long long int x = 174^55; //result is 153 printf("%lld\n", x); } For those curious, it is for a school project where we are implementing the RS...

Persist changes in C

I am developing a database-like application that stores a a structure containing: struct Dictionary { char *key; char *value; struct Dictionary *next; }; As you can see, I am using a linked list to store information. But the problem begins when the user exits out of the program. I want the information to be stored somewhe...

How do I make VC++'s debugger break on exceptions?

I'm trying to debug a problem in a DLL written in C that keeps causing access violations. I'm using Visual C++ 2008, but the code is straight C. I'm used to Delphi, where if an exception occurs while running under the debugger, the program will immediately break to the debugger and it will give you a chance to examine the program state...

Read a file until a character in C

Say I have a file with the format: key1/value1 key2/value2 key3/value3 .... Say I have an array to hold these values: char *data[10][10] How would I read this file and get key1, key2, and key3 into data[0][0], data[1][0], and data[2][0]. Then put value1, value2, and value3 into data[0][1], data[2][1], and data[3][1]. So actually I ...

Clear trailing 0's on a double?

I have a double thats got a value of something like 0.50000 but I just want 0.5 - Is there any way to get rid of those trailing 0's? :) ...

How to port OCaml lib into lib Acsessable from C code?

I have a OCaml library with lots of classes I need some translator to make it from OCaml lib a C lib so to be able to use its methods. How to do such thing? How to port OCaml lib into lib Acsessable from C code? ...

Thread scheduling Round Robin / scheduling dispatch

#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <semaphore.h> #define NUM_THREADS 4 #define COUNT_LIMIT 13 int done = 0; int count = 0; int quantum = 2; int thread_ids[4] = {0,1,2,3}; int thread_runtime[4] = {0,5,4,7}; pthread_mutex_t count_mutex; pthread_cond_t count_threshold_cv; void * inc_c...

Using CreateFileMapping between two programs - C

Hello, I have two window form applications written in C, one holds a struct consisting of two integers, another will receive it using the CreateFileMapping. Although not directly related I want to have three events in place so each of the processes can "speak" to each other, one saying that the first program has something to pass to th...

Help writing getstring function

Im having some trouble writing a getstring function, this is what I have so far. Regards, V const char* getstring() { char *buffer; int i = 255; buffer = (char *)malloc(i*sizeof(char)); *buffer = getchar(); while ( *buffer != '\n' ) { buffer++; *buffer = getchar(); } *buffer = '\0'; ...