Category : string

I have the following code: https://godbolt.org/z/9aqqe5eYh #include<string> #include<sstream> #include<iomanip> #include<iostream> int main() { std::string line = "fa0834dd"; for(int i = 0; i < line.length(); i += 2) { std::stringstream ss; std::uint8_t byte; ss << std::hex << line.substr(i, 2); std::cout << ss.str() << " "; ss >> byte; std::cout << std::hex << std::setw(2) << byte << ..

Read more

I have a tsrange field on my table that I am trying to populate from a prepered statament. db.prepare("insertReservation", "insert into reservations(id, during, person_id, room_id, obs) values (uuid_generate_v4(), $1, $2, $3, $4)"); The time range is a std::string as follows "[16/09/2021 08:00, 16/09/2021 09:00)" When executing the command I got the following error. Failure during ..

Read more

This is the given code. I am accessing each element of the string and trying to multiply it with powers of 8 but, the result is ambiguous. #include<iostream> #include<algorithm> #include<math.h> using namespace std; int od(string s) { reverse(s.begin(),s.end()); int ans=0; for(int i=0;i<s.length();i++) { ans=ans+s[i]*pow(8,i); } return ans; } int main() { string s; cin>>s; cout<<od(s); ..

Read more