Похожие чаты

Hi guys im getting an error message when im trying

to convert an interger into a string (C:\Users\HP\Desktop\Ta\TRON\pseudo ecocash\main.cpp|81|error: invalid use of member 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long long unsigned int]' (did you forget the '&' ?)|) below is the code segment that is getting the error : // Check if the amount is valid
if (amount > 50) {
cout << "you have insufficient credit" << endl;
} else {
cout << "enter the phone number of the recipient " << endl;
cin >> recipient;
string num = to_string(recipient);

// Check if the phone number is valid
if (num.length > 10) { // im getting the error here
cout << "you entered an invalid phone number" << endl;
} else {
cout << "your transaction to " << recipient << " was succesfull" << endl;
}
}
break; // Break after each case

3 ответов

19 просмотров
RYZEN- Автор вопроса

the problem started when i wanted to limit the length of the interger to 10

To post more than a few lines of code, use a pastebin like: * dpaste.org * linkode.org * bin.kv2.dev * hastebin.com If you are stuck in a terminal, you can use ix.io or paste.rs to paste from the CLI: <command to print output> |& curl -F 'f:1=<-' ix.io <command to print output> |& curl --data-binary @- https://paste.rs

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

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

Карта сайта