c

How can I check that I didn't break anything when refactoring?

I'm about to embark on a bout of refactoring of some functions in my code. I have a nice amount of unit tests that will ensure I didn't break anything, but I'm not sure about the coverage they give me. Are there any tools that can analyze the code and see that the functionality remains the same? I plan to refactor some rather isolated...

struct size optimization

I have a structure I would like to optimize the footprint of. typedef struct dbentry_s { struct dbentry_s* t_next; struct dbentry_s* a_next; char *t; char *a; unsigned char feild_m; unsigned char feild_s; unsigned char feild_other; } dbentry; As I understand it, the compiler creates structures in memory as you de...

Delete a file in C

I have written a program that manipulates files and I sometimes to delete a file. So I searched and found the remove() function in the stdio header file in C. The problem is that sometimes works and sometimes not. Sometimes the file is deleted, other perror() shows a message that says permission denied but I have not specified any spec...

Learning C: video course recommendation

I'm required to learn C to help a professor of mine with some lab work. I've got only about 2 weeks to get ready. Anyone can recommend a good course/book, but preferably a video course that's thick and decent (like the MIT open courses style), but anything else that you've had good experience with is welcome too. Thank you all ...

do sem_wating threads cause more switching

I have several threads which act as backup for the main one spending most of their life blocked by sem_wait(). Is it OK to keep them or is it better to spawn new threads only when they need to do actual work? Does kernel switch to threads waiting on sem_wait() and "waste" CPU cycles? Thanks. ...

Help getting started with C using K&R C Programming Language Book

For reasons of self-improvement / broadening my horizons I have decided to learn some of the fundamentals of C using the K&R 'C Programming Language Book'. I have been following along with the exercises, using Bloodhsed DEV C++ 4.9.9.2 as my IDE. I came across the following exercise - counting characters in an input: main() { double ...

How can I check if a string can be converted to a float?

First my context is that of a compiler writer who needs to convert floating point literals (strings) into float/double values. I haven't done any floating point programming the last 15 years so i'm pretty sure this is a total stupid newbie question. double res; errno=0; *res = strtod((const char*)literal,NULL); if (errno==ERANGE) thr...

how to intercept linux signals ? (in C)

hi everyone, I need to intercept and trace signals from any binaries, like strace does it under linux. I don't need a so verbose output like the real one strace. I just want to know how it works, how can I intercept signal and how can I trace them. Thanks in advance :) ...

segmentation fault while assigning structure members in c

Hi, I have two structure in c struct data{ char *name; }; struct lst{ struct lst *next; struct table *data; }; when I'm trying to assign a name like l->data->name = d->name; printf("%s",l->data->name); it gives segmentation fault. So is it because read-only memory or caused by another reason ? ok I solved the problem : ) ...

free throws error when trying to free memory

Hello, Visual Studio 2008 - compiling in C I am writing a linked list application but when I try and free each node I get an exception thrown. The only thing I can think of is that I allocated my memory in the add function, and maybe globaly I cannot free it in another function. Appart from that I can't think of anything. Many thanks ...

what Applications can you make with the programming language Ruby?

What applications can you make with the programming language Ruby? Can you name a few commercial/famous ones written only in Ruby? What I'd really like to know is can you just learn Ruby instead of C/C++ to make commercial software e.g web server, photoshop, desktop applications, even an operating system etc. Except Ruby on Rails whic...

TOPMOST window in full-screen

Hi, I'm playing with a JFrame in Java. I want it to be the topmost window i.e. always on top. The setAlwaysOnTop() works fine, but as soon as I start a movie or a game-window in a full-screen mode then it fails to stay on top. I played around with JNI and handles. My C code for JNI is using SetWindowPos() and this seems to be working ...

sendfile() completion to non-blocking socket

Hi, In my program, I need to check the completion of a sendfile() operation in a non-blocking socket. How can that be done? After checking the documentation and searching on internet, I couldn't find out how to do it ...

Graphics on a bootloader

Managed to create a simple bootloader... and with VESA 2.0 I managed to change the resolution to 1024x768x32, also managed to setup a Linear Frame Buffer... Where can I find tutorials for using the frame buffer? Like lets say to display a picture before it finishes to load? So far I saw one sample on how to "draw" an ipod...called CdPod...

Tips for embedding a longer text in source code, as in languages like Perl?

Possible Duplicate: Something like print END << END; in C++? In a shell script or in a perl program the so called "HERE" documents are commonly used for longer text, e.g. Perl: my $t=<<'...'; usage: program [options] arg1 arg2 options: -opt1 description for opt1 -opt2 description for opt2 ...

Using c library in objective c

I'm having trouble creating this c struct in objective c. typedef struct huffman_node_tag { unsigned char isLeaf; unsigned long count; struct huffman_node_tag *parent; union { struct { struct huffman_node_tag *zero, *one; }; unsigned char symbol; }; } huffman_node; ...

How to generate Debug symbols with Makefile for C? [Linux]

Hi I'm trying to use GDB and KDEvelop to debug a console app under Knoppix VM. KDevelop and GDB don't break at my breakpoints. I suspect it's because they don't have debug symbols. If I'm correct how do I need to change my Makefile to create those. Maybe the problem is somewhere else? Regards, Ariel ...

Problem with bin/sh -i in a forked process, error: 'can't access tty, job control turned off'

I'm writing a cgi-bin program for my Sheevaplug (running the default Ubuntu install) that displays a shell in a browser page. It is a single C program that is placed in the cgi-bin folder and viewed in a browser. It automatically launches a daemon and the daemon forks an instance of the shell. The cgi-bin communicates with the daemon via...

fpga: choosing c++ to program fpga

I keep hearing mostly from electrical engineers that C is used for fpga work. What about C++? Are there any disadvantages to using C++? I would think that the parallelism desired when programming for hardware would be better served by C++ more than C, no? Also what do I use after that to make compatible c++ with the hardware? ...

How to avoid "error LNK2005:" (already defined stdlib functions) when compiling libpng with Microsoft Visual Studio '08?

(Why I am trying to do this: I have had no luck in using the pre-built binaries for libpng on Windows (despite many hours of trial and error), and therefore am now trying to compile it myself. I found this helpful blog post concerning this, complete with a Microsoft Visual Studio 2008 project file, but unfortunately have still not been a...