当前位置: 首页>>代码示例>>C++>>正文


C++ ListPtr::print方法代码示例

本文整理汇总了C++中ListPtr::print方法的典型用法代码示例。如果您正苦于以下问题:C++ ListPtr::print方法的具体用法?C++ ListPtr::print怎么用?C++ ListPtr::print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListPtr的用法示例。


在下文中一共展示了ListPtr::print方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printf

int
main ()
{
    int a;
    short b;
    APTR ptr;
    WORD c;
    struct List l;
    ListPtr lptr;
    struct Node n;

    /* Store an int in a BE 16bit data type */
    c = 15;
    a = c;  // Check if all conversions work
    b = c;

    // Try to print the data
    printf ("Must be 15 15 15: %d %d %d\n", a, b, (int)c);
    putchar ('\n');

    // Same with a pointer
    ptr = &lptr;

    // Note that the pointer must be casted but the compiler will print
    // a warning if the cast is missing:
    //	warning: cannot pass objects of type `APTR' through `...'
    // These three lines must print the same values.
    printf ("APTR %p %p\n", &lptr, (void *)ptr);
    hexdump (&ptr, sizeof (ptr));
    ptr.print (); putchar ('\n');
    putchar ('\n');

    // Same with a pointer
    char * p1;
    STRPTR p2;

    p1 = "hello";
    p2 = p1;

    // Note that the pointer must be casted but the compiler will print
    // a warning if the cast is missing:
    //	warning: cannot pass objects of type `STRPTR' through `...'
    // The first line must print two equal pointers and the second line
    // must print two times "hello".
    printf ("string %p %p\n", p1, (void *)p2);
    printf ("%s %s\n", p1, (UBYTE *)p2);
    putchar ('\n');

    // Show the contents of the memory (to prove that the actual data is BE)
    printf ("Contents of p1 (host endianess) and p2 (big endian):\n");
    hexdump (&p1, sizeof (p1));
    hexdump (&p2, sizeof (p2));
    putchar ('\n');

    // Same with a structure
    lptr = &l;
    // Print address of list header
    printf ("&lptr %p\n", &lptr);
    // Print list pointers (host and BE) which must be equal (otherwise the
    // BE pointer is not converted correctly).
    printf ("List %p %p\n", &l, (void *)lptr);
    // Show that it's really a BE pointer
    hexdump (&lptr, sizeof (lptr));
    // Print the real contents of the variable in host endianess
    lptr.print ();
    putchar ('\n');
    putchar ('\n');

    // Try some functions on the list
    NEWLIST(lptr);
    printf ("NewList %p %p %p\n", (void *)(l.lh_Head), (void *)l.lh_Tail, (void *)l.lh_TailPred);
    printf ("NewList %p %p %p\n", (void *)(lptr->lh_Head), (void *)lptr->lh_Tail, (void *)lptr->lh_TailPred);
    hexdump (&l, sizeof (struct List));
    putchar ('\n');

    ADDHEAD(lptr, &n);
    printf ("&Node %p\n", &n);
    printf ("AddHead %p %p %p\n", (void *)l.lh_Head, (void *)l.lh_Tail, (void *)l.lh_TailPred);
    putchar ('\n');

    return 0;
}
开发者ID:michalsc,项目名称:AROS,代码行数:82,代码来源:test.c


注:本文中的ListPtr::print方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。