易截截图软件、单文件、免安装、纯绿色、仅160KB

ruby c++

While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file can be found here: wtmplist.c.
Disclaimer: I’m not resposible if you should destroy something with your newfound skills, nor am I responsible if you should suddenly get the urge to leave your wife/loved ones in favor of Ruby.
Table of Contents:
What to Extend?
How Do I Want the Interface to Be?
Get to it! #include <ruby.h>
Groundwork.
Making it Compile.
Collect the Data th Make Available.
Adding More Functionality.
Test Your New Library.
What to Extend?
Obviously you start by figuring out what you want to extend Ruby with. Some library missing, or better implemented in C? Some library you wrote yourself and want to be able to use from Ruby scripts?
I have a project coming up where I’ll have to look into /var/log/wtmp to get login entries, and didn’t find any classes/modules that made this possible in Ruby. There are documented (through Man) C functions to access the structures in the file, so I started to look at the introductions to extending Ruby (regrettably I somehow forgot about the Pickaxe at this point, but Kjetil reminded me after I had been cursing for a while).
Moving on to the next step …
How Do I Want the Interface to Be?
The point here is to think how you would like the information and methods represented in Ruby. In my case, I want to read in all entries in wtmp, and have them available in a list of some sort. In Ruby that means using the array. So an Array of entries doesn’t sound too bad. To make things cleaner, I’ll also put it in a module. This maps to this Ruby code (roughly):
module Wtmp
class List < Array
def initialize
# open wtmp
# wtmp.each_struct


相关文档:

经典c/c++算法

二分查找的代码.
int bfind(int* a,int len,int val)
{
    int m = len/2;
    int l = 0;
    int r = len;
    while(l!=m && r!= m)
    {
        if(a[m] > val)
  & ......

Ruby快速入门(二):变量

上一篇文章
说了Ruby的安装和运行,也简单的说了下类和对象。这里主要谈谈变量的问题。
先说常量
。如果变量名以大写字母开头,就被视为常量,但通常是所有字母都大写。但和其他语言不同,在Ruby中,你仍然可以改变常量的值,当然解释器会抛出一个警告:
#! /usr/bin/ruby
CONSTANT = 1
print "#{CONSTANT}\n&qu ......

C/C++ 内置类型的数值范围

Data   Type   Ranges  
  C/C++   recognizes   the   types   shown   in   the   table   below.  
   
  Type   Name   Bytes   Other   Names   Range   of   Values    
&nb ......

Linus为什么不用C++写Linux内核?

在最近的一个关于LKML的讨论中,Linus给出了为什么不用C++来写Linux内核的理由:
"In fact, in Linux we did try C++ once already, back in 1992. It sucks. Trust me - writing kernel code in C++ is a BLOODY STUPID IDEA.
“事实上,我们曾经尝试过用C++来写,是在1992年的时候。很糟糕。相信我--用C++来写内核 ......

PHP >C++转换工具

   毋庸置疑,PHP是一种非常棒的动态网页制作语言,他和C的极高相似性,使得它的语法学起来
很容易,他有很多类似C语言库函数的东西,还有像日期,字符串和时间函数等,这使得它很容
易开发相当复杂的应用程序。
    当PHP应用到关键web站点上,如何保证质量将会变得很关键。然而,PHP并不是一 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号