Tutorial by Examples: c

Cross Platform Portability Runs on Windows, Mac OS X, Linux, and virtually every variant of unix. Event driven programming Trigger events based on variable read / write / unset. Trigger events when a command is entered or left. Trigger events when a I/O channel (file or network) becom...
ValueConverted To StringConverted To NumberConverted To Booleanundefinded"undefined"NaNfalsenull"null"0falsetrue"true"1false"false"0NaN"NaN"false"" empty string0false" "0true"2.4" (numeric)2.4true"test" (non nu...
class base { }; class derived: public base { }; int main() { base* p = new derived(); delete p; // The is undefined behavior! } In section [expr.delete] §5.3.5/3 the standard says that if delete is called on an object whose static type does not have a virtual destructor: if the...
In C++ methods that differs only by const qualifier can be overloaded. Sometimes there may be a need of two versions of getter that return a reference to some member. Let Foo be a class, that has two methods that perform identical operations and returns a reference to an object of type Bar: class ...
A lot of users find themselves in a situation where they just want to copy, move or delete a line quickly and return to where they were. Usually, if you'd want to move a line which contains the word lot below the current line you'd type something like: /lot<Esc>dd<C-o>p But to boost...
This is a basic in-app keyboard. The same method could be used to make just about any keyboard layout. Here are the main things that need to be done: Create the keyboard layout in an .xib file, whose owner is a Swift or Objective-C class that is a UIView subclass. Tell the UITextField to use t...
A Static variable declared locally is not destructed and does not lose its value when the Sub procedure is exited. Subsequent calls to the procedure do not require re-initialization or assignment although you may want to 'zero' any remembered value(s). These are particularly useful when late bindin...
Streams can be built that reference themselves and thus become infinitely recursive. // factorial val fact: Stream[BigInt] = 1 #:: fact.zipWithIndex.map{case (p,x)=>p*(x+1)} fact.take(10) // (1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880) fact(24) // 620448401733239439360000 // the ...
This example adds a new rectangle to the canvas every 1 second (== a 1 second interval) Annotated Code: <!doctype html> <html> <head> <style> body{ background-color:white; } #canvas{border:1px solid red; } </style> <script> window.onload=(functio...
This example animates a clock showing the seconds as a filled wedge Annotated Code: <!doctype html> <html> <head> <style> body{ background-color:white; } #canvas{border:1px solid red; } </style> <script> window.onload=(function(){ // canva...
This example loads and animates and image across the Canvas Important Hint! Make sure you give your image time to fully load by using image.onload. Annotated Code <!doctype html> <html> <head> <style> body{ background-color:white; } #canvas{border:1px solid re...
During mousemove you get flooded with 30 mouse events per second. You might not be able to redraw your drawings at 30 times per second. Even if you can, you're probably wasting computing power by drawing when the browser is not ready to draw (wasted == across display refresh cycles). Therefore it m...
<#@ template language="C#" #> //Language of your project <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" ...
You can create a UIColor object using an image pattern by using the UIColor(patternImage:_) method. btn.backgroundColor = UIColor(patternImage: UIImage(named: "image")!)
Intro The Graphics class allows you to draw onto java components such as a Jpanel, it can be used to draw strings, lines, shapes and images. This is done by overriding the paintComponent(Graphics g) method of the JComponent you are drawing on using the Graphics object received as argument to do the...
If you need to clamp a number to keep it inside a specific range boundary function clamp(min, max, val) { return Math.min(Math.max(min, +val), max); } console.log(clamp(-10, 10, "4.30")); // 4.3 console.log(clamp(-10, 10, -8)); // -8 console.log(clamp(-10, 10, 12)); // ...
Invented by John McCarthy around 1958, Lisp (List Processor) has continued to grow into an entire family of languages. Since StackOverflow is more about practical programming problems, typically problems will involve actual Lisp dialects or derived languages and their implementations. Problems that...
A common and task of someone using the Linux Command Line (shell) is to search for files/directories with a certain name or containing certain text. There are 2 commands you should familiarise yourself with in order to accomplish this: Find files by name find /var/www -name '*.css' This will...
th elements are very commonly used to indicate headings for table rows and columns, like so: <table> <thead> <tr> <td></td> <th>Column Heading 1</th> <th>Column Heading 2</th> </tr...
Before making a pull request, it is useful to make sure that compile is successful and tests are passing for each commit in the branch. We can do that automatically using -x parameter. For example: git rebase -i -x make will perform the interactive rebase and stop after each commit to execute mak...

Page 408 of 826