In ruby,
begin
# ...
rescue
# ...
end
won't catch exceptions that aren't subclasses of StandardError. In C,
rb_rescue(x, Qnil, y, Qnil);
VALUE x(void) { /* ... */ return Qnil; }
VALUE y(void) { /* ... */ return Qnil; }
will do the same thing. How can I rescue Exception => e from a ruby C extension (instead of just rescue => e)...
Hi,
I am writing a commandline calculator in C, and it would be very useful if it had the ability to move the cursor each time you close (for example) a parenthesis highlighting the previous one, like in emacs, etc.
For example, if you launch emacs, and type:
(blah)
then for a while after you type the closing parenthesis, the first ...
Is there anyone with a working piece of sample C code that implements LiveView using the Canon EDSDK? The sample code in the documentation looks great until you get to this bit:
//
// Display image
//
Yup, that's it. They don't show how to BLT an image to a window using the data retrieved from the camera. They just say, "Display...
Hello!
I'm doing a benchmark with two versions of a function to filter a linked list, one that receives a predicate function as an argument, and one in which the predicate is built into the function using a "macro template". I would expect the first to run more slowly, because it is making a function call on every iteration, but on my b...
The formula simply isn't executing. I tried using printf to debug and it printed out 0 for i at the end of the code
#include <stdio.h>
int main()
{
int i, base, height;
printf("Lumber Cross-Sectional Moment of Section\n");
printf("Size Area Inertia Modulus\n");
for (i = 0; i > 35; i++)
{
if (i == 6 || i == 12 || i == 18|...
a=(0-100)
when x=0, a should be 0
when x=100, a should be 100
the data needs to bell curve towards the 100 mark, so that once x passes 100 a will remain at 100 and not go over.
Explanation and application follows:
We have a number of rows of data that are counted as good, bad or questionable.
If a row is bad we count it as full value...
I'm working with what should be a fairly basic iteration. I understand that I could accomplish it with Ruby code, but I am working already in a C extension, so I would prefer to keep this function in C with the rest of the code- especially since this should work (one way or another) without issue.
The issue is with rb_block_call. Here ...
Suppose I have a string "qwerty" and I wish to find the index position of character e in it. How do I do it in C? (In this case the index would be 2)
I found strchr function but that returns a pointer to the character and not the index.
Please help me out!
Thanks, Boda Cydo.
...
I am writing a program to capture socket network flow to display network activity.
For this, I was wondering if there is any way I can determine the socket type from the socket descriptor.
I know that I can find socket family using getsockname but I could not find a way to find socket type.
For instance, I want to find if this socket w...
what is the function of #?
...
Hi,I wonder why other languages do not support this feature. What I can understand that C / C++ code is platform dependent so to make it work (compile and execute) across various platform, is achieved by using preprocessor directives. And there are many other uses of this apart from this. Like you can put all your debug printf's inside #...
I have learned the basics of graph data structures. Now I want to implement all the structure/algorithms/operations that can be performed on graphs.
Please share some useful links wherein I can get started doing graph implementations in C.
...
What is the output of the following and what's the reason behind this?
main()
{
printf("%%%%");
}
The answer is "%%", but I don't know why.
...
C programming, are there any good ways to manage path strings rather than using C string API like strcat on linux? The equivalent of Windows' PathAppend would be great. Thank you!
...
this program is a book library that works via software.the problem is that when i sort the books by price and print them,they never get sorted!
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
static int count;
struct book
{
int bookid;
char name[30];
char author[30];
float price;
};
struct book b[40];
void add(voi...
Recently, I downloaded a copy of mysql source code from their source tree. but i am not sure how can i compile the code. i do not quite understand the different processes involved in c++ software building. after i have built the code, how can i install it? or do i need to make? or how do i even know if the 'build' is successful, it print...
I want to store event time.
I found these two functions, but don't know which one is faster.
...
I made a static library with GCC. Building of the library was OK.
When I use it the linker throws undefined reference errors on some functions. But nm says the functions are defined and exported in the static library (marked with T). I know about the linking order that I need to put the libraries after that module that needs them so thi...
Possible Duplicate:
What are quines? Any specific purpose to have them?
How to write a self reproducing code (prints the source on exec)?
please tell me full detail about it.
...
I have a set of C files that I would like to use. Can I just copy them to my include directory, or do I have to compile them. I would think they would be compiled in the final binary.
...