红羊家园

未出土时便有节,待凌云处更虚心(竹)

jianghongfei ID:jiangredsheep
139074次访问,排名530好友0人,关注者1
jiangredsheep的文章
原创 175 篇
翻译 2 篇
转载 38 篇
评论 69 篇
最近评论
mohroq:wow gold,
HateMath:谢谢。
zgl_dm:你好:
在 第一步中,需要生成 perlxsi.c ,我输入了相同的命令,怎么没有得到 perlxsi.c 呢?请指教。谢谢
cangwu_lee:收藏了
jwouba:的确是比较全面的,就是有点缺陷,没有一点参考型的回答,这样也让应聘者心里有个底.
希望作者能够尽快续帖.
文章分类
收藏
    相册
    life
    校友笑容
    研究
    bla bla
    孙志岗主页
    我的space,来吧!(RSS)
    linux
    mylxiaoyi的专栏(RSS)
    matlab
    zjliu
    NLP蜘蛛网
    bill_lang
    svm resources
    SVM3
    SVMers
    SVMers2
    海洁blog(RSS)
    车万翔主页(RSS)
    高立奇blog(RSS)
    perl
    chaoslawful.(RSS)
    编程艺术
    中国龙(RSS)
    葡萄架下的牵牛花
    旧时好友
    张冠男(RSS)
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    转载 C++ string Class 使用收藏

    新一篇: 利用visual source safe管理代码 | 旧一篇: 自然语言处理及计算语言学相关术语中英对译表(A~L)

    C++ string class

    The C++ Standard Template Library (STL) contains a string class that is used in several computer science classes. In order to use the string class you should include the following statements:
    #include <string>
    using std::string;

    The following examples assume these declarations and initial values for each:

    string s = "abc def abc";
    string s2 = "abcde uvwxyz";
    char c;
    char ch[] = "aba daba do";
    char *cp = ch;
    unsigned int i;

    Stream input cin >> s; Changes the value of s to the value read in. The value stops at whitespace.
    Stream output cout << s; Writes the string to the specified output stream.
    Line input getline(cin, s); Reads everything up to the next newline character and puts the result into the specified string variable.
    Assignment s = s2;s = "abc";
    s = ch; s = cp;
    A string literal or a string variable or a character array can be assigned to a string variable. The last two assignments have the same effect.
    Subscript s[1] = 'c';
    c = s[1];
    Changes s to equal "acc def abc"
    Sets c to 'b'. The subscript operator returns a char value, not a string value.
    Length i = s.length();
    i = s.size();
    Either example sets i to the current length of the string s
    Empty? if(s.empty()) i++;
    if(s =
    = "") i++;
    Both examples add 1 to i if string s is now empty
    Relational operators if (s < s2) i++; Uses ASCII code to determine which string is smaller. Here the condition is true because a space comes before letter d
    Concatenation

    s2 = s2 + "x";
    s2 += "x";

    Both examples add x to the end of s2
    Substring

    s = s2.substr(1,4);
    s = s2.substr(1,50);

    The first example starts in position 1 of s2 and takes 4 characters, setting s to "bcde". In the second example, s is set to "bcde uvwxyz". If the length specified is longer than the remaining number of characters, the rest of the string is used. The first position in a string is position 0.
    Substring replace s.replace(4,3,"x"); Replaces the three characters of s beginning in position 4 with the character x. Variable s is set to "abc x abc".
    Substring removal s.erase(4,5);
    s.erase(4);
    Removes the five characters starting in position 4 of s. The new value of s is "abc bc".
    Remove from position 4 to end of string. The new value of s is "abc ".
    Character array to string s = ch; Converts character array ch into string s.
    String to character array cp = s.c_str(); Pointer cp points to a character array with the same characters as s.
    Pattern matching

    i = s.find("ab",4);

    if(s.rfind("ab",4) != string::npos)
       cout << "Yes" << endl;

    The first example returns the position of the substring "ab" starting the search in position 4. Sets i to 8. The find and rfind functions return the unsigned int string::npos if substring not found. The second example searches from right to left starting at position 4. Since the substring is found, the word Yes is printed.

    Because of a bug in the bgunix version of the g++ compiler, writing a string variable under setw control doesn't work. You need to use the c_str member function, like this:
    cout << setw(15) << s.c_str() << endl;

    发表于 @ 2006年03月10日 08:14:00|评论(loading...)|编辑

    新一篇: 利用visual source safe管理代码 | 旧一篇: 自然语言处理及计算语言学相关术语中英对译表(A~L)

    评论

    #HateMath 发表于2008-04-24 14:47:04  IP: 58.217.195.*
    谢谢。
    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © redsheep