Tutorial by Examples: c

This example requires the headers <algorithm>, <locale>, and <utility>. C++11 To trim a sequence or string means to remove all leading and trailing elements (or characters) matching a certain predicate. We first trim the trailing elements, because it doesn't involve moving any el...
Step 1: Open a Workbook Step 2 Option A: Press Alt + F11 This is the standard shortcut to open the VBE. Step 2 Option B: Developer Tab --> View Code First, the Developer Tab must be added to the ribbon. Go to File -> Options -> Customize Ribbon, then check the box for developer. ...
In Python 2, reduce is available either as a built-in function or from the functools package (version 2.6 onwards), whereas in Python 3 reduce is available only from functools. However the syntax for reduce in both Python2 and Python3 is the same and is reduce(function_to_reduce, list_to_reduce). A...
Following is an implementation that demonstrates how an object can be serialized into its corresponding JSON string. class Test { private int idx; private String name; public int getIdx() { return idx; } public void setIdx(int idx) { this.idx = idx; ...
ALTER TABLE Employees DROP COLUMN salary; This will not only delete information from that column, but will drop the column salary from table employees(the column will no more exist).
A custom component that takes the type of a component as input and creates an instance of that component type inside itself. When the input is updated, the previously added dynamic component is removed and the new one added instead. @Component({ selector: 'dcl-wrapper', template: `<div #...
This example is a quick setup of Angular 2 and how to generate a quick example project. Prerequisites: Node.js v4 or greater. npm v3 or greater or yarn. Open a terminal and run the commands one by one: npm install -g @angular/cli or yarn global add @angular/cli depending on your choi...
Simple: NSString *newString = @"My String"; From multiple strings: NSString *stringOne = @"Hello"; NSString *stringTwo = @"world"; NSString *newString = [NSString stringWithFormat:@"My message: %@ %@", stringOne, stringTwo]; Usi...
The main difference is that double-quoted String literals support string interpolations and the full set of escape sequences. For instance, they can include arbitrary Ruby expressions via interpolation: # Single-quoted strings don't support interpolation puts 'Now is #{Time.now}' # Now is #{Time...
Ruby provides several ways to create a String object. The most common way is using single or double quotes to create a "string literal": s1 = 'Hello' s2 = "Hello" The main difference is that double-quoted string literals are a little bit more flexible as they support interpo...
Concatenate strings with the + operator: s1 = "Hello" s2 = " " s3 = "World" puts s1 + s2 + s3 # => Hello World s = s1 + s2 + s3 puts s # => Hello World Or with the << operator: s = 'Hello' s << ' ' s << 'World' puts s # => ...
Tuples are created using generic types Tuple<T1>-Tuple<T1,T2,T3,T4,T5,T6,T7,T8>. Each of the types represents a tuple containing 1 to 8 elements. Elements can be of different types. // tuple with 4 elements var tuple = new Tuple<string, int, bool, MyClass>("foo", 123, t...
To access tuple elements use Item1-Item8 properties. Only the properties with index number less or equal to tuple size are going to be available (i.e. one cannot access Item3 property in Tuple<T1,T2>). var tuple = new Tuple<string, int, bool, MyClass>("foo", 123, true, new MyC...
Lets assume you have a class called Person with just name private class Person { public String name; public Person(String name) { this.name = name; } } Code: Gson g = new Gson(); Person person = new Person("John"); System.out.println(g.toJson(person)); /...
Lets assume you have a class called Person with just name private class Person { public String name; public Person(String name) { this.name = name; } } Code: Gson gson = new Gson(); String json = "{\"name\": \"John\"}"; Person person ...
String json = "{\"name\": \"John\", \"age\":21}"; JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject(); System.out.println(jsonObject.get("name").getAsString()); //John System.out.println(jsonObject.get("age").getAs...
In Python 2, range function returns a list while xrange creates a special xrange object, which is an immutable sequence, which unlike other built-in sequence types, doesn't support slicing and has neither index nor count methods: Python 2.x2.3 print(range(1, 10)) # Out: [1, 2, 3, 4, 5, 6, 7, 8, 9...
With any variadic function, the function must know how to interpret the variable arguments list. With the printf() or scanf() functions, the format string tells the function what to expect. The simplest technique is to pass an explicit count of the other arguments (which are normally all the same ...
Use the following steps to create a topic: Click Create New Topic on the tag's dashboard. Name the topic. Provide detailed examples in the "Examples" section. If you have more to share, use the "Syntax," "Parameters," and "Remarks" sections. You have ...
A topic is made up of several sections: Title: What is the subject of the topic. Search existing topics first to make sure you are not repeating content that already exists. Topics already covered elsewhere on Stack Overflow may be deleted. Versions: The versions where the material covered by the ...

Page 67 of 826