NumOfElements containing data in string array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kenneth6
    New Member
    • Mar 2007
    • 79

    NumOfElements containing data in string array

    string apple[100];

    apple is a string array with max size of 100.
    but not all of them containing data,
    how can i find the number of elements containing data??
    it should be <= 100
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by kenneth6
    string apple[100];

    apple is a string array with max size of 100.
    but not all of them containing data,
    how can i find the number of elements containing data??
    it should be <= 100
    Count them using a loop?

    kind regards,

    Jos

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      The string size() method will tell you if a particular string has data.

      BTW: Since you are using a string, which means you are using C++. Then why are you using an array instead of a vector??

      Comment

      Working...