Hi, So many people think determines the question now is totally crazy, but I intersession simple. Why you should by possibility std:: string using char instead? Should I use in C + +, char if it is not at all? If so why, if not why?
NEN 0 terminated string array of chars is if I'm not mistaken ... : I think the problem is not due to char or string but the program itself you can also view course NEN array of chars and make everything end with \ 0 ... When the strings will automatically stop .. made. ! Example: char [80] was hot as fit only 80 characters purely .. defacto one could reinschreiben but also because 100 is character NEN anywhere where he says where there fit only 80 characters purely .. when the string \ 0 scheduling is in it!
Generally you can continue to work with char array. Only with std:: string everything much easier. Only a few examples: - The size must not be known beforehand. So no predetermination, memory allocation, and the whole stuff - As said before you have to forget about it, that your table ends with a null character. The null termination makes the String class for you - Comparisons can you do then (but elegant as strlen (...), or?) Code: string a="abc"; string b="def"; if (a==b) cout << "stimmt ja gar nicht" << endl; You can be the practical methods of the String class, for example the length to determine a string Code: int nLength = strTest.length(); but looks very intuitive etc., etc. There are certainly thousands of other benefits that the string class with you so that it is definitely worthwhile to deal a bit with it ...
But it's worth it just to advance to deal with char arrays, and to understand what makes any string before it is used the simplicity and safety's sake ...
So, if you want to use strings only, without knowing what that is, one should std:: Take the string, since he (masculine is still true, right?: Eek IMHO prevents some things that one done quickly. Most painful things like buffer overflow issue with the known sequences, or strings that because there is no '\ 0' is the back turn, when, or save time mitausgeben just yet NEN part of the memories, or, conversely, that one myself some variables in memory overrides, which can be really funny. At best, I think then the cases in which one overwrites the return address, and attempts to continue the program at some point, probably nothing in the executable is more: rolleyes:. But as I said, if you wilsst learn what is behind the string, then quietly take the zero-terminated strings. But it also functions as strncpy and co, so you do not hackers and their exploits door to open it: p