Tutorial by Examples: c

The var keyword allows a programmer to implicitly type a variable at compile time. var declarations have the same type as explicitly declared variables. var squaredNumber = 10 * 10; var squaredNumberDouble = 10.0 * 10.0; var builder = new StringBuilder(); var anonymousObject = new { One =...
Copying a partial array with the static Array.Copy() method, beginning at index 0 in both, source and destination: var sourceArray = new int[] { 11, 12, 3, 5, 2, 9, 28, 17 }; var destinationArray= new int[3]; Array.Copy(sourceArray, destinationArray, 3); // destinationArray will have 11,12 and...
Sometimes we need to make a lot of POST requests to one or many different endpoints. To deal with this scenario, we can use multi_curl. First of all, we create how many requests as needed exactly in the same way of the simple example and put them in an array. We use the curl_multi_init and add eac...
Elm Reactor is the essential tool for prototyping your application. Please note, that you will not be able to compile Main.elm with Elm Reactor, if you are using Http.App.programWithFlags or Ports Running elm-reactor in a projects directory will start a web server with a project explorer, that all...
To create a XML using DOMDocument,basically, we need to create all the tags and attributes using the createElement() and createAttribute() methods and them create the XML structure with the appendChild(). The example below includes tags, attributes, a CDATA section and a different namespace for the...
Following the 'Form Request Validation' example, the same Request Class can be used for POST, PUT, PATCH so you do not have to create another class using the same/similar validations. This comes in handy if you have attributes in your table that are unique. /** * Get the validation rules that a...
Just like most other C-style languages, each statement is terminated with a semicolon. Also, a closing tag is used to terminate the last line of code of the PHP block. If the last line of PHP code ends with a semicolon, the closing tag is optional if there is no code following that final line of co...
Anonymous classes were introduced into PHP 7 to enable for quick one-off objects to be easily created. They can take constructor arguments, extend other classes, implement interfaces, and use traits just like normal classes can. In its most basic form, an anonymous class looks like the following: ...
Assertations mean that a condition should be checked and if it's false, it's an error. For static_assert(), this is done compile-time. template<typename T> T mul10(const T t) { static_assert( std::is_integral<T>::value, "mul10() only works for integral types" ); re...
A default constructor is a type of constructor that requires no parameters when called. It is named after the type it constructs and is a member function of it (as all constructors are). class C{ int i; public: // the default constructor definition C() : i(0){ // member initial...
A destructor is a function without arguments that is called when a user-defined object is about to be destroyed. It is named after the type it destructs with a ~ prefix. class C{ int* is; string s; public: C() : is( new int[10] ){ } ~C(){ // destructor definition ...
See below for a simple example of how to use async/await to do some time intensive stuff in a background process while maintaining the option of doing some other stuff that do not need to wait on the time intensive stuff to complete. However, if you need to work with the result of the time intensiv...
See below for a simple example of how to use a BackgroundWorker object to perform time-intensive operations in a background thread. You need to: Define a worker method that does the time-intensive work and call it from an event handler for the DoWork event of a BackgroundWorker. Start the execu...
Subscripts can be used to simplify retrieving and setting elements in an array. Given the following array NSArray *fruit = @[@"Apples", @"Bananas", @"Cherries"]; This line [fruit objectAtIndex: 1]; Can be replaced by fruit[1]; They can also be used to set an...
Subscripts can also be used with NSDictionary and NSMutableDictionary. The following code: NSMutableDictionary *myDictionary = [@{@"Foo": @"Bar"} mutableCopy]; [myDictionary setObject:@"Baz" forKey:@"Foo"]; NSLog(@"%@", [myDictionary objectForKey:...
You can add subscripting to your own classes by implementing the required methods. For indexed subscripting (like arrays): - (id)objectAtIndexedSubscript:(NSUInteger)idx - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx For keyed subscripting (like dictionaries): - (id)objectForKey...
In PCRE, matched groups used for backreferences before a recursion are kept in the recursion. But after the recursion they all reset to what they were before entering it. In other words, matched groups in the recursion are all forgotten. For example: (?J)(?(DEFINE)(\g{a}(?<a>b)\g{a}))(?<a...
In PCRE, it doesn't trackback after the first match for a recursion is found. So (?(DEFINE)(aaa|aa|a))(?1)ab doesn't match aab because after it matched aa in the recursion, it never try again to match only a.
the steps in this example will use the following project structure as a demonstration and we intend to export it to the "GHTuts" Repository [Note that the Repo doesn't exist yet on github] but leave the "SensitiveProject" without publish as it contains some passwords, keys, et...
C++14 Those following complex user literals are declared in the namespace std::literals::complex_literals, where both literals and complex_literals are inline namespaces. Access to these operators can be gained with using namespace std::literals, using namespace std::complex_literals, and using nam...

Page 317 of 826