Passing Pointer To An Array Of Arrays Through Function

前端 未结 6 1762
南旧
南旧 2021-01-21 14:00

There is a pointer-to-an-Array of Arrays i.e. NameList in the code. I want the contents of each of the Arrays in the Pointer(NameList) to get printed one by one. The below co

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-21 14:34

    Judging by your "answer" (you really should have edited your original post and added this information), you probably want something like this:

    void draw_all_sprites(Sprite *sprites, size_t num_sprites)
    {
        Sprite *cur_sprite;
        size_t i;
    
        for(i = 0; i < num_sprites; ++i)
        {
            draw_sprite(cur_sprite);
            ++cur_sprite;
        }
    }
    

    A fairly simple for loop to iterate through elements in an array.

提交回复
热议问题