What do you want to save?
Add Code snippet
New code examples
-
C++ 2022-03-22 13:25:16
arrow operator c++
/* the arrow operator is used for accessing members (fields or methods) of a class or struct it dereferences the type, and then performs an element selection (dot) operation */ #include <iostream> using std::cout; class Entity { public: con... Add solution -
C++ 2022-03-18 18:00:09
basic data types in c++ hackerrank solution
#include <iostream> using std::cin; using std::cout; using std::endl; using std::fixed; int main() { int a; long b; char c; float d; double e; cin>>a>>b>>c>>d>>e; cout<<a<<endl; cout<<... Add solution -
C++ 2022-02-02 17:45:33
array declaration c++
#include <iostream> using std::cout; int a[] = { 1, 2, 3, 4, 5 }; int counta() { return sizeof( a ) / sizeof( a[ 0 ] ); // works, since a[] is an array } int countb( int b[] ) { return sizeof( b ) / sizeof( b[ 0 ] ); // fails, since b[... Add solution -
C++ 2021-11-19 14:25:09
how to get a random element from a vector c++ string
#include <iostream> #include <vector> using std::string; int main() { std::vector <string> some_vector {"pizza", "burger", "fries", "chicken"}; string random = some_vector[rand() % some_v... Add solution -
C++ 2021-11-09 03:13:11
C++ std::string find and replace
#include <string> #include <regex> using std::string; string do_replace( string const & in, string const & from, string const & to ) { return std::regex_replace( in, std::regex(from), to ); } string test = "Remove all spa... Add solution -
SQL 2021-11-08 21:15:23
sqlite3 get data from table c
#include <stdio.h> #include <string> using std::string; #include <sstream> using std::stringstream; #include "sqlite3.h" bool find_employee(int _id) { bool found = false; sqlite3* db; sqlite3_stmt* stmt; strin... Add solution -
TypeScript 2021-11-07 09:17:14
make a vector of an objects c++
#include <vector> using std::vector; class MyClass { .... }; vector<MyClass> myVector( 100, MyClass() ); /* myVector now contains 100 objects of type MyClass, built with the default constructor */ vector<MyClass> myVector2; // MyVecto... Add solution -
Other 2021-11-02 21:46:05
c++ sha256
/*************************************************************************** C++ sha256 function SHA-256 is the most popular hash function in the SHA-2 family at the time of writing. It provides 128 bits of security for digital signatures and hash-only ... Add solution