How to get size c++ dynamic array

前端 未结 5 1935
南方客
南方客 2020-12-02 02:31

I\'m studying C++ and I need to create structure Airplane and work with it.

My structure Airplane.h

#include \"stdafx.         


        
5条回答
  •  离开以前
    2020-12-02 03:06

    The problem with entering type is that the input buffer contains the new line character after entering n. You should use member function ignore to clear the buffer before using function getline.

    As for your second question then in general you should track the size of a dynamically allocated array yourself. Or you can set the last element of the array as NULL and use it as a sentinel.

提交回复
热议问题