c

Is C really "disguised assembly"?

As a C++ programmer I have now decided to learn C to have "more control" over what I write. Are there any syntactical features in C which lead to rather unpredictable assembler code? Like virtual functions in C++ Is C disguised assembler? I would quite like that idea. ...

from JS to iphone dev - what's the best language to start with?

I am a total beginner and would like to eventually learn to develop for the iphone. I have just done a beginner's CS course where the language we learned was JavaScript. We studied basic concepts like: variables, arrays, loops (for,while,if,if..else..), properties and functions. I'm wondering if I am starting in the right/wrong place b...

Ajax based progress bar

I am developing a progress bar using Ajax. My client side code is working fine, but I have issue at server side. I am using C based CGI. if(i == inc && pb_inc<=100) { fptr = fopen("progress_bar.txt", "w"); fprintf(fptr,"%d", j); fclose(fptr); pb_inc++; } basically I am increasing progress bar after certain number of bytes. What I see ...

EXC_BAD_ACCESS when calling avcodec_encode_video

I have an Objective-C class (although I don't believe this is anything Obj-C specific) that I am using to write a video out to disk from a series of CGImages. (The code I am using at the top to get the pixel data comes right from Apple: http://developer.apple.com/mac/library/qa/qa2007/qa1509.html). I successfully create the codec and con...

Implementing a scrabble solver.

Hello, before I ask anything, just letting everyone know that this is for fun and I have posted all of my code that I have so far; will post more as things are fixed/implemented), sorry for the lengthy post! I have two questions here and I will post all of my code below. - 1) I can't seem to figure out why when inputting 12+ letters wi...

parsing of mathematical expressions

(in c90) (linux) input: sqrt(2 - sin(3*A/B)^2.5) + 0.5*(C*~(D) + 3.11 +B) a b /*there are values for a,b,c,d */ c d input: cos(2 - asin(3*A/B)^2.5) +cos(0.5*(C*~(D)) + 3.11 +B) a b /*there are values for a,b,c,d */ c d input: sqrt(2 - sin(3*A/B)^2.5)/(0.5*(C*~(D)) + sin(3.11) +ln(B)) /*max lenght of formula is 250 characters...

Can someone port this to C?

I've spent the last few hours trying to port this to C, with no success. Can someone please help? function zerofill($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a>>1); $a &= (~$z); $a |= 0x40000000; $a = ($a>>($b-1)); } else { $a = ($a>>$b); } return $a; } ...

Types in a struct in C

In this article : http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/language/ref/clrc03defst.htm What's means the sentence "In C, a structure member may be of any type except "function returning T" (for some type T)" Thanks for all the answers! ...

how is data stored at bit level according to "Endianness" ?

I read about Endianness and understood squat... so I wrote this main() { int k = 0xA5B9BF9F; BYTE *b = (BYTE*)&k; //value at *b is 9f b++; //value at *b is BF b++; //value at *b is B9 b++; //value at *b is A5 } k was equal to A5 B9 BF 9F and (byte)pointer "walk" o/p was 9F BF b9 A5 so I get it byte...

How to do hex8 encoding in c?

I am trying to encode a string in hex8 using c. The script I have right now is: int hex8 (char str) { str = printf("%x", str); if(strlen(str) == 1) { return printf("%s", "0", str); } else { return str; } } In this function, I will need to add a 0 ahead of the string if the length is less than 1. I don't know why I'm getting: p...

Comparing two speech sounds

I need to be able to determine if two sounds are very similar. The goal is to have a very limited vocabulary (10 or 15) of short one or two syllable words, then compare a captured sound to determine if it is one of those items with all the usual variability in environmental and capture conditions. The idea is that the user can issue a fe...

C problem, left of '->' must point to class/struct/union/generic type ??

Hello! Trying to understand why this doesn't work. I keep getting the following errors: left of '->nextNode' must point to class/struct/union/generic type (Also all the lines with a -> in the function new_math_struct) Header file #ifndef MSTRUCT_H #define MSTRUCT_H #define PLUS 0 #define MINUS 1 #define DIVIDE 2 #defi...

Embed Text File in a Resource in a native Windows Application

I have a C++ Windows program. I have a text file that has some data. Currently, the text file is a separate file, and it is loaded at runtime and parsed. How is it possible to embed this into the binary as a resource? ...

Limit Output in C

In C, I would like to limit the string to the first 8 characters. For example, I have: char out = printf("%c", str); How can I make it so it only returns the first 8 characters? ...

hashtable implementation in C?

Hello, I was wondering if you knew of a robust implementation of a hashtable in C. I'm looking for something other than ghashtable in glib. Thanks. ...

use callback function to report stack backtrace

Assume I have the following: typedef struct { char *name; char binding; int address; } Fn_Symbol //definition of function symbol static Fn_Symbol *fnSymbols; //array of function symbols in a file statc int total; //number of symbol functions in the array and file static void PrintBacktrace(int sigum, siginfo_t ...

my version of strlcpy

Hello, gcc 4.4.4 c89 My program does a lot of string coping. I don't want to use the strncpy as it doesn't nul terminate. And I can't use strlcpy as its not portable. Just a few questions. How can I put my function through its paces to ensure that it is completely safe and stable. Unit testing? Is this good enough for production? s...

determine name of running function from eip address?

Given a void *eip and an array of struct function symbols that contain the address, symbolic name, and binding of all function symbols in the file, how do I determine the function running at the time of the error? ...

Help making this code run faster for spoj.

I've been doing a few of the challenges on the Sphere Online Judge, but I can't seem to get the second problem (the prime generator) to run within the time limit. Does anyone have any tips for increasing the speed of the following code? #include <stdio.h> #include <math.h> int is_prime(int n); void make_sieve(); void fast_prime(int n);...

how do I print a #defined constant in GDB?

As per subject. I have some constants hash defined like so: #define CONST 40 I've set a break point in my program. How do I print the value of that constant? (I know I can just look at the source code, but I want to be sure of it) ...