c

Intrinsically faster: Forth or C?

This isn't an attempt to start a flame war about Language A Versus Language B, nor Compiler A Versus Compiler B, it's simple a question on your personal experiences: what language is faster and, hopefully, use less resources: C or Forth? I welcome ANY opinion, hopefully based in real experience. ...

How do I access a raw sector of disk in XP with a c program?

I want to know that how to access a sector of the hard disk in Windows XP with a C program? ...

How does this code generate the map of India?

I got this code from somewhere. It prints the map of India, But how this code works? I can't understand anything of this. If somebody knows, please help me to understand this. #include "stdio.h" main() { int a,b,c; int count = 1; for (b = c = 10; a = "- FIGURE?, UMKC,XYZHello Folks,\ TFy!QJu ROo TNn(ROo...

How Can I control another programs?

Hi, my question is general for all languages, but I'm using only C, so, I would like to get answer in this one. My question is, How Can I control the behavior of another applications that I didn't write? For example: How Can I fill this entry box (in this site) using C? Do I need to control the browser? (I'm using firefox.) Still in ...

sqrt() function not working with variable arguments

I don't know if I'm missing something obvious, but it appears that I'm unable to compute square roots of a variable in C; the sqrt() function only seems to work on constants. This is my code: #include <math.h> #include <stdio.h> int main() { double a = 2.0; double b = sqrt(a); printf("%f", b); return 0; } When I run t...

Performance differences between Python and C

Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network...

Functions and header files (ansi c)

This is a question from job interview.Let's say we have "a.c" source file with some function and "a.h" as its header file.Also we have main.c file which calls that function.Now let's suppose we have "a.h" and "a.o"(object file) and a.c is unavailable.How do we call this function now? (I had a hint that we need to use function pointers.An...

What does "#define STR(a) #a" do?

I'm reading the phoneME's source code. It's a FOSS JavaME implementation. It's written in C++, and I stumbled upon this: // Makes a string of the argument (which is not macro-expanded) #define STR(a) #a I know C and C++, but I never read something like this. What does the # in #a do? Also, in the same file, there's: // Makes a strin...

What language should we use to let people extend our terminal/sniffer program?

Hello, We have a very versatile terminal/sniffer application which can do all sorts of things with TCP, UDP and serial connections. We are looking to make it extensible -- i.e, allow people to write their own protocol parsers, highlighters, etc. We created a C-like language for extending the product, and then discovered that for some ...

What does "#define FOO(template)" do?

I've found some weird C++ preprocessor clauses, like: #define COMPILER_FLOAT_ENTRIES_DO(template) and #define COMPILER_FLOAT_ENTRIES_DO(template) \ template(jvm_fadd) \ template(jvm_fsub) \ template(jvm_f2d) What does passing "template" reserved word to a #define, and calling template(something) mean? I couldn't find any...

What's a time efficient algorithm to copy unaligned bit arrays?

I've had to do this many times in the past, and I've never been satisfied with the results. Can anyone suggest a fast way of copying a contiguous bit array from source to destination where both the source and destination's may not be aligned (right shifted) on convenient processor boundaries? If both the source and destination's aren't...

iOS — Determining whether Accelerate.framework is available at runtime

Is there any way to determine whether the Accelerate.framework is available at runtime from straight C or C++ files? The examples I've found for conditional coding all seem to require Objective-C introspection (e.g., respondsToSelector) and/or Objective-C apis (e.g., UIDevice's systemVersion member) ...

Convert characters in a c string to their escape sequences

Hi, I need a function like string ToLiteral(string input) from this post. Such that char *literal = to_literal("asdf\r\n"); Would yield literal ==> "asdf\\r\\n". I've googled around, but not been able to find anything (guess that I've must be using the wrong terms). However, I assume that a library with this functionality must be out...

No Symbols loaded in mixed C# C(win32) project using VS2010

My project has several new C# modules and one C module (not C++) compiled using win32 system calls. I'm using the PInvoke interop layer to call the C code from the C#. The C function is getting called. All modules are writing to a single bin directory and all write pdb files. On running, and then stopping at a breakpoint right be...

C Linux open source projects

Sorry if this has been asked elsewhere. I am a C,Win32 developer and want to learn similar stuff in the linux world. What are the best and easy opensource projects for learning similar stuff on Linux. Like in C,Win32 world i want to start off with User space and onto advance stuff like internals,device drivers etc. I am interested in N...

What's so special about file descriptor 3 on linux?

I'm working on a server application that's going to work on Linux and Mac OS X. It goes like this: start main application fork of the controller process call lock_down() in the controller process terminate main application the controller process then forks again, creating a worker process eventually the controller keeps forking more wo...

Assign multiple values to array in C

Is there any way to do this in a condensed form? GLfloat coordinates[8]; ... coordinates[0] = 1.0f; coordinates[1] = 0.0f; coordinates[2] = 1.0f; coordinates[3] = 1.0f; coordinates[4] = 0.0f; coordinates[5] = 1.0f; coordinates[6] = 0.0f; coordinates[7] = 0.0f; return coordinates; Something like coordinates = {1.0f, ...};? ...

Reading from a file

hello i got a problem with reading from a file, i am trying to read from a file using fscanf() and i cant seem to sort it out. i try to read the file line by line and putting the string in a variable (buffer) each time but i cant understand how the while loop is suppose to be looking like thanks in advance the file that i want to read f...

Strange C program behaviour

Hi guys, I really have a strange situation. I'm making a Linux multi-threaded C application using all the nitty-gritty memory stuff involving char* strings, and I'm stuck in a really odd position. Basically, what happens is, using POSIX threads, I'm reading and writing to a two-dimensional char array, but it has unusual errors. You hav...

GtkScrolledWindow + WebkitWebView Scrolling

Hey I am trying to make a GTK IRC client that uses webkit to display its messages. The webview is within a ScrolledWindow, and I want the scrolledwindow to scroll to the bottom everytime it gets too big. I've tried changing the vadjustment value of the scrolledwindow when a message is added but this doesn't seem to work at all. It kee...