@gameraccoon when i write Getline(cin, name[i]) Instead cin name I got this error!
What do you mean by "except cin name"?
That is strange, can you paste the code somewhere (e.g. pastebin) so I can copy and execute it?
Ill send file for you
I found this, you probably need to do cin.ignore(), before first getline call. https://stackoverflow.com/questions/36374710/using-multiple-getline-calls-to-read-multiple-lines
By the way, I can give you some suggestions how this code can be improved (from readability and maintainability perspective), do you need it?
yes i need it, i wanna know your suggestions bro, appreciate it
First of all, instead of using raw arrays you can use std::vector. It will allow you to do the same logic but without need to call delete manually (so you don't have a chance to forget to do it, especially if your function will have multiple returns in future). So you can just create variables of types std::vector<char> and std::vector<std::string>> and call resize(size) to make them allocate 3 items for you. Then you can use it like you already using it and the items will be deallocated in the end of the function automatically. The pattern that vector uses called RAII. Instead of having a separate array for first letter, you can do one of the following: Either do to upper on the first symbol in the cout call. E.g. cout << toupper(name[i].at(0)) << ...;. Or in your loop you can assign result of toupper back to the first symbol. Something like name[i][0] = toupper(name[i][0]);. I would prefer the second way. If you use vector instead of raw array, you can use range-based loops instead of iterating over i. So your loops will look like: for (auto& line : name){ And you will use line instead of name[i]. And a minor suggestion, it's better not to use using namespace std in real code. It is good for code examples to make them shorter, but in real code it can create issues. https://www.geeksforgeeks.org/using-namespace-std-considered-bad-practice/ Other than that, the code looks good to me. Nice use of transform 👍
Обсуждают сегодня