c

Find what unknown function does in C using gdb

Hi, I have a function m(int i, char c) which takes and returns a char between "-abc...xyz" and also takes an integer i. Basically I have no way to see the source code of the function but can call it and get the return value. Using gdb/C, what's the best way to decipher what the function actually does? I've tried looking for patterns us...

PIC C - USB_CDC_GETC() and retrieving strings.

Hi all, I'm programming a PIC18F4455 Microcontroller using PIC C. I'm using the USB_CDC.h header file. I have a program on the computer sending a string such as "W250025". However, when I use usb_cdc_getc() to get the first char, it freezes. Sometimes the program sends only 'T', so I really want to just get the first character. Why ...

C sockets, chat server and client, problem echoing back.

Hi This is my chat server : #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <string.h> #define LISTEN_Q 20 #define MSG_SIZE 1024 struct userlist { int sockfd; struct sockaddr addr; struct userlist *next; }; int main(int argc, char *arg...

Why malloc memory in a function and free it outside is a bad idea?

if this is a bad idea, how to allocate memory in the function? ...

How to acquire still webcam image

I need some help deciding what to use to acquire an image from a webcam. I want to acquire a single image. I know you can typically acquire a still image at a higher resolution than a single video frame. Currently, I am using MATLAB's image acquisition toolbox.. which apparently only supports obtaining frames in video mode(so lower res...

how to do bar chart in c

i have written a program that prints out the integers in the same order as the input with 5 numbers per line. That is, the first 5 integers will be printed in the first line; the next 5 integers in the next line; andso on. and also i was trying to print out the numbers in a bar chart formatt:like 81-105 ( 1) x 56-80 ( 5) xxxxx 6-11(5) ...

What's the difference between unsigned long/long/int in c/c++?

It seems all of them take 4 bytes of space, so what's the difference? ...

How to capture full screen in c using visual studio

Is it possible to capture full screen in visual studio (VC++), so that user don't have to press ATL+Enter. Kindly guide me how I can make it possible. ...

What is size_t in C?

Hi, I am getting confused with size_t in C. I know that it is returned by the sizeof operator. But what exactly it is? Is it a datatype? Let's say I have a for loop int i; or size_t i; //which one should i use? for(i = 0; i < some_size; i++) ...

Problem in implementing progress control using threading!

hello all, I am new to the concept of threading in C..so I find it difficult to implement that in my function...I have a simple application in which i want to display a progress bar at a particular place..In a particular funtion I will read files(in a for loop) for some manipulations(regarding my application) ...while its readin...

How should I protect against hard link attacks?

I want to append data to a file in /tmp. If the file doesn't exist I want to create it I don't care if someone else owns the file. The data is not secret. I do not want someone to be able to race-condition this into writing somewhere else, or to another file. What is the best way to do this? Here's my thought: fd = open("/tmp/some-b...

What is the relationship between Turing Machine & Modern Computer ?

Possible Duplicate: What is the relationship between Turing Machine & Modern Computer ? I heard a lot that modern computers are based on Turing machine. I just cannot build a bridge from a conceptual Turing Machine to a real modern computer. Could someone help me build this bridge? Below is my current understanding. I thin...

Is single float assignment an atomic operation on the iPhone?

I assume that on a 32-bit device like the iPhone, assigning a short float is an atomic, thread-safe operation. I want to make sure it is. I have a C function that I want to call from an Objective-C thread, and I don't want to acquire a lock before calling it: void setFloatValue(float value) { globalFloat = value; } ...

Unexpected result in C algebra for search algorithm.

Hi, I've implemented this search algorithm for an ordered array of integers. It works fine for the first data set I feed it (500 integers), but fails on longer searches. However, all of the sets work perfectly with the other four search algorithms I've implemented for the assignment. This is the function that returns a seg fault on lin...

Strange code behaviour?

I have a C code in which I have a structure declaration which has an array of int[576] declared in it. For some reason, i had to remove this array from the structure, So I replaced this array with a pointer as int *ptr; declared some global array of same type, somewhere else in the code, and initialized this pointer by assigning the glo...

Block until an event has completed.

Hello, gcc 4.4.2 c89 I have a function that has to run (config_relays). It make a call to a API function called set_relay, then the code has to wait before continuing until the event for set_relay event has completed. The set_relay is any Async call. i.e. void run_processes() { switch() { case EV_RELAY_SET: br...

multi thread apps crashes in release mode

Hello, I'm using Visual Studio 2008 (programming in c). I've a weird problem I worte a program that has 2 threads that runs simultaneously, a recording thread (using audio card to record into memory) and a translation thread (using a speech engine to recognize the words). when I run my program in debug mode (aka setting a breakpoint in ...

error: incompatible types in assignment

My C code #include <stdio.h> #include <stdlib.h> #include "help.h" int test(int x, P *ut) { int point = 10; ut->dt[10].max_x = NULL; } int main(int argc, char** argv) { return (EXIT_SUCCESS); } my help.h file code typedef struct{ double max_x; double max_y; }X; typedef struct{ X dt[10]; }P; I got an err...

Marshal struct to unmanaged array

I have a C# struct to represent a cartesian vector, something like this: public struct Vector { private double x; private double y; private double z; //Some properties/methods } Now I have an unmanaged C dll that I need to call with P/Invoke. Some methods expect a double[3] parameter. The unmanaged C signat...

How to implement progressbar(to show progress) using threading concept in win 32?

I am trying to show a progress bar while my process is going on...in my application there will be a situation where I gotta read files and manipulate them(it will take some time to complete)..want to display a progress bar during this operation..the particular function I am calling is an win 32 ...so if you check my code below i am upto ...