What does ** mean in the following code?
char **argv; |
It declares argv as a pointer that points to a char pointer. It is equivalent to the following code.
char *argv[]; |
Processing a text file line by line is a common thing programmers do. There are many related classes in the Java I/O package and this may get confusing. This post shows 4 different ways of reading a file line by line in Java. 1. FileInputStream and BufferedReader private static void readFile1(File fin) throws IOException { … Read more
This is a method that accepts a range (max) and a number (n), returns an array of n random numbers. n: size of random number array max: largest available number (exclusive) For example: Input: n=5, max=100 Output: an array containing 5 random numbers whose range is from 0 to 99. public static HashSet<Integer> getNRandom(int n, … Read more
What does ** mean in the following code?
char **argv; |
It declares argv as a pointer that points to a char pointer. It is equivalent to the following code.
char *argv[]; |
Pipe is neat. A pipe is a way to connect the output of one program to the input of another program without any temporary file. This simple test contains a Java program and a C++ program. The output of Java program is used as input for “wc” command, and the output is then used by … Read more
This shell program mainly demonstrate how to use $? to find out the exit status of command.
After a command executes, if you input to terminal: echo $?, you will get 0 or 1 to indicate the status of execution.
The following is a simple program with comments.
What is a process?
In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.
How compiler works is not easy to explain in one sentence. The best way is to use an example. A compiler is a computer program that transforms source code written in a high-level programming language into a lower level language. Basically, a compiler consists the following phases: Lexical Analysis, Syntax Analysis, Semantic Analysis, IR Generation, … Read more
Strategy pattern is also called policy pattern. Here is a story about Strategy pattern. Suppose Mike sometimes speeds when driving, but he doesn’t always do that. He may be stopped by a police officer. It’s possible that the police is very nice, who would let him go without any ticket or with a simple warning. … Read more
In brief, Observer Pattern = publisher + subscriber. Observer pattern has been used in GUI action listener. Swing GUI example shows how action listener works like an observer. The following is a typical example about head hunter. There are two roles in this diagram – HeadHunter and JobSeeker. Job seekers subscribe to a head hunter, … Read more
Here is a example showing how to use constructor function in C++.
vs. Overall, dot(.) is for object itself, arrow(->) is for pointer. A good example worth a thousand words. The following example should be a good one. #include <iostream> using namespace std; class Car { public: int number; void Create() { cout << "Car created, number is: " << number << "\n" ; … Read more
Virtual keyword determines if a member function of a class can be over-ridden in its derived classes. Here is a simple example to show this.
Eclipse is a good tool for developing C++ programs in Windows. Setting up the environment sometimes cause problems for a lot of developers. Here are steps that can make it work under your Windows system. 1. update eclipse galileo to helios. 2. add CDT plugin 3. install MinGW 4. Create a sample project, and see … Read more
This tutorial belongs to Eclipse JDT Tutorial Series. ASTParser can use its setKind() method to set source to be parsed as a compilation unit, single expression, a sequence of statements, or a sequence of class body declarations. parser.setKind(ASTParser.K_COMPILATION_UNIT);parser.setKind(ASTParser.K_COMPILATION_UNIT); Any of those four can not handle a single independent method. This is not pleasant. Following the … Read more
JDT is supported by 3 pillars: Java Model, Search Engine, and AST. It is a handy tool for manipulating Java source code. However, the handy tool comes with a steep learning curve even for an experienced Java developer and there are just not enough proper code examples. This page summarizes the code examples for using … Read more