我看过《女人不哭》 章子君的曲折生活,奋斗历程也让我更坚定的度过了那段日子。她最后还是成功了,事业and情感。从她身上,我学会: 坚强、忍耐、等待

发布新日志

  • LR_strdup

    2007-09-04 09:21:19

    Duplicates a string.

    char *strdup ( const char *string );

    string
    The string that is duplicated.

    strdup duplicates a string.

    简单的字符串复制:

    Action() {

      char *a="aa",*b;
      b=(char *)strdup(a);
      lr_output_message("%s",b);
      lr_output_message("%s",a);
    }

    结果:

    Action.c(7): aa
    Action.c(8): aa

  • LR_strcmp and LR_stricmp

    2007-09-04 09:03:37

    一、strcmp

    Compares string1 and string2 to determine the alphabetic order.

    int strcmp ( const char *string1, const char *string2 ); //注意是int

    string1
    The first string that is compared.
    string2
    The second string that is compared.

    strcmp compares string1 and string2 to determine the alphabetic order.

    返回值:

    Returns a value indicating the lexicographical relation between the strings:

    Return value
    Descrīption
    <0
    string1 is less than string2
    0
    string1 is the same as string2
    >0
    string1 is greater than string2
     
    二、stricmp
    (与strcmp的区别仅为忽略大小写)

    Performs a case-insensitive comparison of two strings.

    int stricmp ( const char *string1, const char *string2 );

    string1
    The first string for comparison.
    string2
    The second string for comparison.

    stricmp performs a case-insensitive comparison of two strings.

    Returns a value indicating the lexicographical relation between the strings:

    Return value
    Descrīption
    <0
    string1 is less than string2
    0
    string1 is the same as string2
    >0
    string1 is greater than string2

    脚本说明:

    The following example compares two strings, string1 and string2, which are identical except for the word "quick" which is lowercase in string1 and uppercase in string2. strcmp, which is case-sensitive, returns an unequal comparison. stricmp, which ignores case, returns an equal one.

    下面的例子比较了两个字符串,string1和string2,除了单词"quick"在string1中为小写字母,在string2中为大写字母外,其他字母都是相同的。strcmp,是大小写敏感的,这个函数会返回一个不相同的结果。stricmp,会忽略大小写,返回相同的结果

     

    #include "web_api.h"


    Action() {

         int result;
         char tmp[20];
         char string1[] = "The quick brown dog jumps over the lazy fox";
         char string2[] = "The QUICK brown dog jumps over the lazy fox";

         result = strcmp( string1, string2 ); /* Case-sensitive comparison */

         if( result > 0 )
              strcpy( tmp, "greater than" );
         else if( result < 0 )
              strcpy( tmp, "less than" );
         else
              strcpy( tmp, "equal to" );

         lr_output_message( "strcmp: String 1 is %s string 2", tmp );

         result = stricmp( string1, string2 ); /* Case-insensitive comparison */

         if( result > 0 )
              strcpy( tmp, "greater than" );
         else if( result < 0 )
              strcpy( tmp, "less than" );
         else
              strcpy( tmp, "equal to" );

         lr_output_message( "stricmp: String 1 is %s string 2", tmp );

         return 0;
    }

    结果:

    Action.c(20): strcmp: String 1 is greater than string 2
    Action.c(31): stricmp: String 1 is equal to string 2

  • LR_strchr and LR_strrchr

    2007-09-04 08:39:48

    一、strchr

    char *strchr ( const char *string, int c );

    string
    The string that is searched.
    在哪个字符串进行寻找?
    c
    The character that is searched for in the string.
    寻找哪个字符?

    strchr returns the pointer to the first occurrence of a character in a string.

    strchr指向第一次出现寻找到的字符的位置

    二、strrchr

    (与strchr相对应的最后一个字符串)

    char *strrchr ( const char *string, int c );

    string
    The string that is searched.
    c
    The character that is searched for in the string.

    strrchr finds the last occurrence of a character in a string.

     

    #include "web_api.h"


    Action() {

         char *string = "His Excellency txhe Duke of Exeter";
         char *first_x, *last_x;

         first_x = (char *)strchr(string, 'x');
         lr_output_message("The first occurrence of x: %s", first_x);
         last_x = (char *)strrchr(string, 'x');
         lr_output_message("The last occurrence of x: %s", last_x);

         return 0;
    }

    /*
    这个函数的意义是:strchr:找出从字符串开始的第一个x字符,并把
    这个x和x后面的字符全部显示出来
    那么strrchr就是找到从给定字符串开始最后一个x字符,并把
    最后这个x和它后面的字符全部显示出来
    运行结果:
    Action.c(11): The first occurrence of x: xcellency txhe Duke of Exeter
    Action.c(13): The last occurrence of x: xeter
    */

  • LR_strcat and LR_strcpy

    2007-09-03 16:24:50

    一、strcat

    Concatenates two strings.

    char *strcat ( char *to, const char *from );

    to
    The string at the end of which the from string is concatenated.
    from
    The string concatenated to the end of the to string.

    strcat concatenates two strings.

    二、strcpy

    Copies one string to another.

    char *strcpy ( char *dest, const char *source );

    dest
    The destination string into which source is copied. (目的)
    source
    The string that is copied. (源)

    strcpy copies one string to another.

    注意:

     
    注意将字符串或者字符串常量放在一个字符变量中,而且字符变量需要设置长度,如果不设置会出错。如下:
    Action.c(16): Error: C interpreter run time error: Action.c (16):  Error -- memory violation : Exception ACCESS_VIOLATION received.
    Action.c(16): Notify: CCI trace: Action.c(16): strcat(0, 0x00e3023e "aaa")
    .
    Action.c(16): Notify: CCI trace: Compiled_code(0): Action()
    .
     
    Action()
    {
     char *a="aaa";
     char *b="bbb";
     char c[1024];
        
    char fullpath[1024], *filename = "logfile.txt";
     
         strcpy(fullpath, "把它考到fullpath中");
         strcat(fullpath, "【这个字符连接到fullpath后面】");
         strcat(fullpath, filename);
     
         lr_output_message("Full path of file is %s", fullpath);
     

        strcat(c,a);
     strcat(c,b);
     strcat(c,a);
     lr_output_message("%s",a);
     lr_output_message("%s",b);
     lr_output_message("%s",c);
         return 0;
    }
  • 将参数化内容输出到.txt文件中

    2007-07-22 00:25:49

    将参数化内容输出到文件中

    文件位置:C:\jiris.txt

    输出方式为追加输入。~

    其实没有什么意义~~只是学一下写文件~

    char *filename = "c:\\jiris.txt";


    Action() {

         long file;
        
     
         if ((file = fopen(filename, "a" )) == NULL) {

              lr_output_message("Unable to create %s", filename);
              return -1;
         }


         fprintf(file, "%s",lr_eval_string("{number}"));
         lr_output_message("%s",lr_eval_string("{number}"));
         fprintf(file,"\n");
         fclose(file);

         return 0;

    }

  • 1. fopen【翻】

    2007-07-21 16:31:33

    my english level is listed~~~~
    大概意思,如果有错误,欢迎指出~~
    ----------
    Opens a file for buffered I/0.
    打开文件到IO缓冲器
    FILE *fopen ( const char *filename, const char *access_mode );
    filename
    The name of the file to open.
    想要打开的文件名
    access_mode
    The type of access mode: r, w, a or r+, w+, a+, where the "+" sign indicates that the file must already exist.
    存取方式:r, w, a or r+, w+, a+, 当+符号存在的时候,文件必须已经窜自傲

    The access_mode parameter serves also to specify whether we want to open the file as text or binary, adding t or b characters to this access mode string.

    存取方式参数也可以制定我们要打开的文件类型,是.txt还是二进制格式,用t或者b表示

    t
    Text mode. In text mode the end of file is assumed to be at first Ctrl+Z character. Some conversions can occur reading and writing with End Of Line / Feedback characters depending on your compiler and your Operating System.
    文本模式。在这种模式中,文件末尾假定是第一次出现Ctrl+Z的地方。在读或者写最后字符的时候,可能会发生一些转换。返回的字符取决于你的编译器和你的操作系统。
    b
    Binary mode. End of file is reached at last byte of the file. No conversions.
    二进制模式。最后一个字符就是文件的结束。不会发生转换。

    Do not include operating system header files (e.g. stdio.h) in scrīpts. This will result, however, in some types, including the FILE type used here, to be undefined. Instead, substitute a long for the FILE type.

    不要在脚本中定义头文件,如stdio.h。如果包含了FILE类型在这里使用的话,可能会有这样的结果,就是FILE未定义。此时,可以用long声明FILE~

数据统计

  • 访问量: 4259
  • 日志数: 6
  • 建立时间: 2007-07-21
  • 更新时间: 2007-09-04

RSS订阅

Open Toolbar