Oops general doubt

why we update char array ( char by char ) instead of putting whole string once ? i have seen this in the videos but i didnt understand why is he doing that

@sktg99 Yes, we can definitely use a string, but to make the students more comfortable with character arrays and the use of β€˜\0’ that procedure has been followed in the video.
If you feel comfortable with character arrays you can use the string class by all means.
Hope this helps.

its not about string class, I think u didnt get my point
im asking why cant we declare C.name=β€œBMW” directly instead of declaring individual characters(like C.name[0]=β€˜B’ and so on)

You can declare that way as well, there is no problem in that.
Some students face problem visualizing character array as a string, it for them that the has been made like that, else I don’t see any issue in directly declaring the whole array.

okay thank u very much

1 Like