Похожие чаты

Can someone explain this error?

10 ответов

13 просмотров
Caroline- Автор вопроса

@gameraccoon when i write Getline(cin, name[i]) Instead cin name I got this error!

Caroline- Автор вопроса
Caroline
@gameraccoon when i write Getline(cin, name[i]) In...

That is strange, can you paste the code somewhere (e.g. pastebin) so I can copy and execute it?

Caroline- Автор вопроса

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?

Caroline- Автор вопроса
Pavel
By the way, I can give you some suggestions how th...

yes i need it, i wanna know your suggestions bro, appreciate it

Caroline
yes i need it, i wanna know your suggestions bro,...

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 👍

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта