c

Missing functions in ruby 1.8

I have a ruby gem that I developed with ruby 1.9, and it works. With ruby 1.8, though, it says this when I try to run it: dyld: lazy symbol binding failed: Symbol not found: _RBIGNUM_SIGN Referenced from: /Users/Adrian/Desktop/num_to_bytes/ext/num_to_bytes/num_to_bytes.bundle Expected in: flat namespace dyld: Symbol not found: _RBI...

reading a string with spaces with sscanf

For a project I'm trying to read an int and a string from a string. The only problem is sscanf appears to break reading an %s when it sees a space. Is there anyway to get around this limitation? Here's an example of what I'm trying to do: #include<stdio.h> #include<stdlib.h> int main(int argc, char** argv) { int age; char* buff...

c windows connect() fails. error 10049

The following two pieces of code compile, but I get a connect() failed error on the client side. (compiled with MinGW). Client Code: // thanks to cs.baylor.edu/~donahoo/practical/CSockets/code/TCPEchoClientWS.c #include <stdio.h> #include <winsock.h> #include <stdlib.h> #define RCVBUFSIZE 32 // size of receive buffer void DieWithErr...

calculating min and max of 2-D array in c

This program to calculate sum,min and max of the sum of array elements Max value is the problem, it is always not true. void main(void) { int degree[3][2]; int min_max[][]; int Max=min_max[0][0]; int Min=min_max[0][0]; int i,j; int sum=0; clrscr(); for(i=0;i<3;i++) { for(j=0;j<2;j++) ...

What is the purpose of using -pedantic in GCC/G++ compiler?

Hi, -ansi: tells the compiler to implement the ANSI language option. This turns off certain "features" of GCC which are incompatible with the ANSI standard. -pedantic: used in conjunction with -ansi, this tells the compiler to be adhere strictly to the ANSI standard, rejecting any code which is not compliant. Text ab...

When should carry flag be set in assembly language.

Hi everyone: I'm puzzled by this problem when writting an ARM assembly simulator in C. I've found some similar questions in the forum, but none of them explain how to set the carry flag just using the relationship between two operands and the result. Any reply is appreciated. Thanks in advance. Regard. ...

Hi, I have a C hashing routine which is behaving strangely?

Hi, In this hashing routine: 1.) I am able to add strings. 2.) I am able to view my added strings. 3.) When i try to add a duplicate string, it throws me an error saying already present. 4.) But, when i try to delete the same string which is already present in hash table, then the lookup_routine calls hash function to get an index. ...

Avoiding string copying in Lua

Say I have a C program which wants to call a very simple Lua function with two strings (let's say two comma separated lists, returning true if the lists intersect at all, false if not). The obvious way to do this is to push them onto the stack with lua_pushstring, which works fine, however, from the doc it looks like lua_pushstring but ...

In C: sending func pointers, calling the func with it, playing with EIP, jmp_buf and longjmp

I need to make sure i understand some basic stuff first: how do i pass function A as a parameter to function B? how do i call function A from inside B ? Now for the big whammy: I'm trying to do something along the lines of this: jmp_buf buf; buf.__jmpbuf[JB_PC] = functionA; longjmp(buf,10); Meaning that I want to use longjmp in o...

Tool for detecting memory leaks

How do memory leak detection tools like purify and valgrind work? How can I design and implement my own such tool? ...

Use the right tool for the job: embedded programming

I'm interested in programming languages well suited for embedded programming. In particular: Is it possible to program embedded systems in C++? Or is it better to use pure C? Or is C++ OK only if some features of the language (e.g. RTTI, exceptions and templates) are excluded? What about Java in this domain? Thanks. ...

glut library for Eclipse

hello everyone I'm working with Eclipse under Windows XP, but I can't find there glut library, all I have inside GL are only gl.h, glu.h and glext.h, can somebody please help me import glut library and explain what is this glext.h, thanks in advance for any help ...

Dynamic allocation in C

I'm writing a program and I have the following problem: char *tmp; sprintf (tmp,"%ld",(long)time_stamp_for_file_name); Could someone explain how much memory allocate for the string tmp. How many chars are a long variable? Thank you, I would appreciate also a link to an exahustive resource on this kind of information. Thank you UP...

UTC time stamp on Windows

I have a buffer with the UTC time stamp in C, I broadcast that buffer after every ten seconds. The problem is that the time difference between two packets is not consistent. After 5 to 10 iterations the time difference becomes 9, 11 and then again 10. Kindly help me to sort out this problem. I am using <time.h> for UTC time. ...

How to properly handle signals when using the worker thread pattern?

I have a simple server that looks something like this: void *run_thread(void *arg) { // Communicate via a blocking socket } int main() { // Initialization happens here... // Main event loop while (1) { new_client = accept(socket, ...); pthread_create(&thread, NULL, &run_thread, *thread_data*); p...

C and C++: Array element access pointer vs int

Is there a performance difference if you either do myarray[ i ] or store the adress of myarray[ i ] in a pointer? Edit: The pointers are all calculated during an unimportant step in my program where performance is no criteria. During the critical parts the pointers remain static and are not modified. Now the question is if these static ...

Convert Hexadecimal String to Data

Hi Stack Overflow, I have found a whole lot of different solutions to this problem, but not all of them work, and a lot of them seem somewhat hacky and inefficient. Basically I have a string of hexadecimal data (i.e. "55 AA 41 2A 00 94 55 AA BB BB 00 FF") which I would like to convert to raw data. What is the best way to do this? UPDAT...

How do I make a daemon into a stream in PHP

I have a daemon (written in C, but I assume it does not really matter) which outputs messages with printf, and can get input and do stuff with this input (again, not really important what, but he sends those messages to a different machine to be saved there in the DB). My question, how can I make this daemon to be a stream in PHP, so ...

warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’

I think this code and error is self-explanatory, but I don't know why? Environment: OS: Mac OS X 10.6.1 Compiler: i686-apple-darwin10-gcc-4.2.1 code: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <netdb.h> 4 #include <sys/socket.h> 5 6 int 7 main(int argc, char **argv) 8 { 9 char *ptr, **pptr; 1...

problems with openGl on eclipse

I'm working on Windows XP I have portable version of Eclipse Galileo, but I didn't find there glut so I decided to add it using this link I made all steps and and now I'm trying to compile this code #include "GL/glut.h" #include "GL/gl.h" #include "GL/glu.h" /////////////////////////////////////////////////////////// // Called to draw ...