Tutorial by Examples: c

Italics can be created by surrounding text with either asterisks or with underscores: *Italicized text* _Also italicized_ Result: Italicized text Also italicized
Interface and implementation of a simple category on NSArray, named Filter, with a single method that filters numbers. It is good practice to add a prefix (PF) to the method to ensure we don't overwrite any future NSArray methods. @interface NSArray (PFFilter) - (NSArray *)pf_filterSmaller:(dou...
The following is how to properly use the java.util.Scanner class to interactively read user input from System.in correctly( sometimes referred to as stdin, especially in C, C++ and other languages as well as in Unix and Linux). It idiomatically demonstrates the most common things that are requested ...
Markdown supports adding inline code like this, obtained by wrapping text in backticks: `code here` Alternatively, you can put your inline code between <code> and </code> HTML tags. Consider the following markdown code: `This` is an inline code block! <code>This</code> is...
On StackExchange sites, code snippets may provide optional syntax highlighting. On sites like Stack Overflow the default language is derived from the tags used in the associated question (if applicable). In addition, a code snippet's syntax highlighting language may also be defined by adding an HTML...
Every format type is related to an HTML tag. The First Heading refers to the <h1> tag and is visualized like: Hello World and it's written underlining the text with =: Hello World =========== or by prepending # to the text: # Hello World The Second Heading refers to the <h2&gt...
This is an enum that is also a callable function that tests String inputs against precompiled regular expression patterns. import java.util.function.Predicate; import java.util.regex.Pattern; enum RegEx implements Predicate<String> { UPPER("[A-Z]+"), LOWER("[a-z]+&quot...
One use case for assertion is precondition and postcondition. This can be very useful to maintain invariant and design by contract. For a example a length is always zero or positive so this function must return a zero or positive value. #include <stdio.h> /* Uncomment to disable `assert()`...
In this example, we'll be looking at how to store a credit card using the PayPal vault, then reference that stored credit card to process a credit card transaction for a user. The reason why we would want to use the vault is so that we don't have to store sensitive credit card information on our ow...
The following C source file (which we will call hello.c for demonstration purposes) produces an extension module named hello that contains a single function greet(): #include <Python.h> #include <stdio.h> #if PY_MAJOR_VERSION >= 3 #define IS_PY3K #endif static PyObject *hell...
When an exception object is created (i.e. when you new it), the Throwable constructor captures information about the context in which the exception was created. Later on, this information can be output in the form of a stacktrace, which can be used to help diagnose the problem that caused the excep...
To see the log with changes inline, use the -p or --patch options. git log --patch Example (from Trello Scientist repository) ommit 8ea1452aca481a837d9504f1b2c77ad013367d25 Author: Raymond Chou <[email protected]> Date: Wed Mar 2 10:35:25 2016 -0800 fix readme error link diff ...
For JavaScript, here is the code we recommend for generating, persisting and retrieving a UUID. This could be wrapped in a function can called directly from the PUBNUB.init function rather than the two step inline solution below. // get/create/store UUID var UUID = PUBNUB.db.get('session') || (fun...
You can overload all basic arithmetic operators: + and += - and -= * and *= / and /= & and &= | and |= ^ and ^= >> and >>= << and <<= Overloading for all operators is the same. Scroll down for explanation Overloading outside of class/struct: //operator...
You can overload all comparison operators: == and != > and < >= and <= The recommended way to overload all those operators is by implementing only 2 operators (== and <) and then using those to define the rest. Scroll down for explanation Overloading outside of class/struct: ...
You can overload type operators, so that your type can be implicitly converted into the specified type. The conversion operator must be defined in a class/struct: operator T() const { /* return something */ } Note: the operator is const to allow const objects to be converted. Example: struct ...
You can even overload the array subscript operator []. You should always (99.98% of the time) implement 2 versions, a const and a not-const version, because if the object is const, it should not be able to modify the object returned by []. The arguments are passed by const& instead of by value...
You can overload the function call operator (): Overloading must be done inside of a class/struct: //R -> Return type //Types -> any different type R operator()(Type name, Type2 name2, ...) { //Do something //return something } //Use it like this (R is return type, a and b a...
Using the following code with the format string yyyy/MM/dd hh:mm.ss, we will receive the following output 2016/04/19 11:45.36 // define the format to use String formatString = "yyyy/MM/dd hh:mm.ss"; // get a current date object Date date = Calendar.getInstance().getTime(); //...
Sourcing a file is different from execution, in that all commands are evaluated within the context of the current bash session - this means that any variables, function, or aliases defined will persist throughout your session. Create the file you wish to source sourceme.sh #!/bin/bash export A=...

Page 42 of 826