c

ffmpeg C API documentation/tutorial

I am trying to find documentation to use the ffmpeg C API. It seems that only command line documentation is available. Is there any good documentation/tutorials/links available? ...

Initialize Static Array of Structs in C

I'm implementing a card game in C. There are lots of types of cards and each has a bunch of information, including some actions that will need to be individually scripted associated with it. Given a struct like this (and I'm not certain I have the syntax right for the function pointer) struct CARD { int value; int cost; // ...

Getting Error When Opening Files

I'm developing a simple Text Editor to understand better PocketC language, then I've done this: #include "\\Storage Card\\My Documents\\PocketC\\Parrot\\defines.pc" int filehandle; int file_len; string file_mode; initComponents() { createctrl("EDIT", "test", 2, 1, 0, 24, 70, 25, TEXTBOX); wndshow(TEXTBOX, SW_SHOW); guigetf...

What is the safest way to pass strings around in C?

I have a program in C using Solaris with VERY ancient compatibility it seems. Many examples, even here on SO, don't work, as well as lots of code I've written on Mac OS X. So when using very strict C, what is the safest way to pass strings? I'm currently using char pointers all over the place, due to what I thought was simplicity. So...

EDIT Control Showing Squares Instead Of Returns

I'm playing a little bit with PocketC by doing a simple text editor. But with this code to read and to display the contents of the file on the EDIT control: int filehandle; int file_len; string file_mode; initComponents() { createctrl("EDIT", "test", 2, 1, 0, 24, 70, 25, TEXTBOX); wndshow(TEXTBOX, SW_SHOW); guigetfocus(); }...

Create ntp time stamp from gettimeofday

I need to calculate an ntp time stamp using gettimeofday. Below is how I've done it with comments on method. Look good to you guys? (minus error checking). Also, here's a codepad link. #include <unistd.h> #include <sys/time.h> const unsigned long EPOCH = 2208988800UL; // delta between epoch time and ntp time const double NTP_SCALE_FRAC...

How can I declare and initialize an array of pointers to a structure in C?

I have a small assignment in C. I am trying to create an array of pointers to a structure. My question is how can I initialize each pointer to NULL? Also, after I allocate memory for a member of the array, I can not assign values to the structure to which the array element points. #include <stdio.h> #include <stdlib.h> typedef str...

Ideas for a C/C++ library

I thought one of the best ways to familiarise myself with C/C++, is to make a helpful library. I was maybe thinking like a geometry library, like to calculate areas, surface area, etc. It would be useful in game programming. Or maybe an algebra library, like for different formulas like the distance formula, quadratic formula, etc. Or may...

converting an int to char*

This is a very very basic question and I know one way is to do the following: char buffer[33]; itoa(aq_width, buffer,10); where aq_width is the int, but then I can't guarantee what size of buffer I would need in order to do this... I can always allocate a very large buffer size, but that wouldn't be very nice... any other pretty and s...

windows C system call with spaces in command

I cannot make system calls with spaces in the names and parameters. For example: system("c:\\program files\\something\\example.exe c:\\my files\\example.txt"); I have tried escaping in every way I know how, and NOTHING works. I have tried: system("\"c:\\program files\\something\\example.exe\" \"c:\\my files\\example.txt\""); and s...

'??' is getting converted into '^' in Visual C++. Why is it happening and what is the way out?

'??' gets converted into '^' if I compile mn VC++ program and run it e.g. sprintf( ch, "??") prints out ^ But if I run the same code in Turbo C/C++, there is no such problem. Why is it happening on VC++ on Windows? ...

Is 0x9B (155decimal) a special control character? Why is it missing from ascii tables?

Hi, I'm working on an embedded system, and i'm having dramas getting it to send a certain chunk of data across the serial port. I narrowed it down and found that if a 0x9B is present in the message, it corrupts the message. So i then look up 0x9b (155) on http://www.asciitable.com/, and it's missing! Isn't that a bizarre coincidence! A...

How to Replace only Part of the Variable using #define

#define C_TX_ TX_ #define C_RX_ RX_ enum Test { C_TX_MAC = 0x0100, // Pre-Processor should replace C_TX_ to TX_ C_RX_MAC = 0x0101 // But Not Working. }; int main(int argc, char *argv[]) { cout << TX_MAC; // HOW TO PRINT ? cout << RX_MAC; // HOW TO PRINT ? return true; } Please Help. Thanks in Advance ...

can a program written in C be faster than one written in OCaml and translated to C?

So I have some cool Image Processing algorithm. I have written it in OCaml. It performs well. I now I can compile it as C code with such command ocamlc -output-obj -o foo.c foo.ml (I have a situation where I am not alowed to use OCaml compiler to bild my programm for my arcetecture, I can use only specialy modified gcc. so I will compil...

Project Euler Question 14 (Collatz Problem)

The following iterative sequence is defined for the set of positive integers: n ->n/2 (n is even) n ->3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 40 20 10 5 16 8 4 2 1 It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it ha...

Getting memory section information

Can somebody explain me how the following code works? # if defined(__ELF__) # define __SECTION_FLAGS ", \"aw\" , @progbits" /* writable flag needed for ld ".[cd]tors" sections bug workaround) */ # elif defined(__COFF__) # define __SECTION_FLAGS ", \"dr\"" /* untested, may be writable flag needed */ # endif asm ( "....

Client Server problem with connect() or accept()

Hello, all. I'm having a bit of weird problem with client server program. I have two different kinds of clients trying to connect to one server, one is just more barebone than the other with less things to do. But other wise they are practically the same. While the barebone code can connect to server and server accepts it fine, the elabo...

Writing a C Macro

Hi, I have to write a macro that get as parameter some variable, and for each two sequential bits with "1" value replace it with 0 bit. For example: 10110100 will become 10000100. And, 11110000->00000000 11100000->100000000 I'm having a troubles writing that macro. I've tried to write a macro that get wach bit and replace it if the nex...

Types questions in ANSI C

Hi, I having few questions about typed in ANSI C: 1. what's the difference between "\x" in the beginning of a char to 0x in the beginning of char (or in any other case for this matter). AFAIK, they both means that this is hexadecimal.. so what's the difference. when casting char to (unsigned), not (unsigned char) - what does it mean? ...

OpenCL or CUDA Which way to go?

I'm investigating ways of using GPU in order to process streaming data. I had two choices but couldn't decide which way to go? My criterias are as follows: Ease of use (good API) Community and Documentation Performance Future I'll code in C and C++ under linux. ...