Trying to reverse swap all the characters in a string array, however, it's not outputting right. Does anyone know if I'm heading the right direction?  My code:   #include &lt;string&gt; #include &lt;string.h&gt; #include &lt;iostream&gt; #include &lt;stdio.h&gt; #include &lt;cstring&gt; // for strlen() using namespace std;  void doSwap (char &amp;string1, char &amp;string2) {     char temp;     temp = string1;     string1 = string2;     string2 = temp; }  int main() {     string testingWord = "hello";     int i;      cout &lt;&lt; testingWord &lt;&lt; "\n";      cout &lt;&lt; "\tBelow is testing the swap feature:\n";      for (i = 0; i &lt; testingWord.size() - 1; i++) {         doSwap(testingWord[i], testingWord[i+1]);     }      cout &lt;&lt; testingWord &lt;&lt; "\n"; }   Here is my output:  elloh   Edit: Not trying to do XOR swapping?
How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?
Origin —  Elementary Number Theory — Jones — p35 — Exercise 2.17 — For which primes $p$ is $p^2 + 2$ also prime? Only for $p = 3$. If $p \neq 3$ then $p = 3q ± 1$ for some integer $q$, so $p^2 + 2 = 9q^2 ± 6q + 3$ is divisible by $3$, and is therefore composite. (1) The key here looks like writing $p = 3q ± 1$. Where does this hail from? I know $3q - 1, 3q, 3q + 1$ are consecutive. $p$ is prime therefore $p \neq 3q$? (2) How can you prefigure $p = 3$ is the only solution? Does $p^2 + 2$ expose this? On an exam, I can't calculate $p^2 + 2$ for many primes $p$ with a computer — or make random conjectures. Rank of the $n \times n$ matrix with ones on the main diagonal and $a$ off the main diagonal I want to find the rank of this $n\times n$ matrix \begin{pmatrix} 1 &amp; a &amp; a &amp; \cdots &amp; \cdots &amp; a \\ a &amp; 1 &amp; a &amp; \cdots &amp; \cdots &amp; a \\ a &amp; a &amp; 1 &amp; a &amp; \cdots &amp; a \\ \vdots &amp; \vdots &amp; a&amp; \ddots &amp; &amp; \vdots\\ \vdots &amp; \vdots &amp; \vdots &amp; &amp; \ddots &amp; \vdots \\ a &amp; a &amp; a &amp; \cdots  &amp;\cdots &amp; 1 \end{pmatrix}  that is, the matrix whose diagonals are $1's$ and $a$ otherwise, where $a$ is any real number.  My first observation is when $a=0$ the rank is $n$ and when $a=1$ the rank is $1.$ Then I can assume $a\neq 0, 1$ and proceed row reduction to find its pivot rows. I obtain  \begin{pmatrix} 1 &amp; a &amp; a &amp; \cdots  &amp; a \\ 0 &amp; 1+a &amp; a &amp; \cdots &amp; a \\ 0 &amp; a &amp; 1+a &amp; \cdots &amp; a \\ \vdots &amp; \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\ 0 &amp; a &amp; a &amp; \cdots  &amp; 1+a \end{pmatrix} by subtracting the first row multiplied $a$ for each row below the first, and then divides the factor $(1-a)$,  and stuck there. Any hints/helps? Determine all $f: \mathbb{R} \rightarrow \mathbb{R}$ such that, for all $x, y \in \mathbb{R}$, $$f((x + 1) f(y)) = y (f(x) + 1).$$    Source: Vuong Lam Huy, on a Facebook group. Prove that $f$ has a fixed point . For $f:[a,b]\rightarrow [a,b]$ is a continuous . Prove that $f$ has a fixed point . Is that true if we change $[a,b]$ by $[a,b)$ or $(a,b)$. Find an example where Markov's inequality is tight in the following sense: For each positive integer $a$, find a non-negative random variable $X$ such that $P(X\ge a)=E(X)/a$.   How to do this problem, I am really confused. Also, what is the definition of Markov's inequality? How is the zero flag set in terms of hardware? How to make a process invisible to other users? How could you launch a process and make it invisible to the top command? The process is started by a normal user (not root), and should not be visible to other normal users. How to change the disk space left warning in Windows 7? my disk has over 100GB of free space, but the usage bar in Computer is displayed in red, as if it reached a low space limit. It looks like Windows applies the same 10% or 15% hard disk space value for low space warnings, regardless of if the disk is 50GB in size or 1.5TB, which is not very smart and obsolete for most recent computers.  Is there a Registry key or some place I can change this percentage so the usage bar displays in green, not red?  The hibernation and page files are already reserved (5GB together), so surely the low space warning for a 1.5TB disk should be 5-10GB, not 150GB or more. The way Windows 7 computes the low space limit seems pretty dumb, not much Intellisense there.  This is not a high priority issue, but it makes the Computer applet look pretty stupid and it's irritating every day to see that 100GB of free space is putting my computer in the red. It would also be nice to be able to edit this low limit percentage in Computer/Manage/Storage/Disk Management or directly in the disk properties ("Tools" tab). PostGIS nearest points with ST_Distance, kNN I need to obtain on each element on one table the closest point of another table. The first table contains traffic signs and the second one the Entrance Halls of the town. The thing is that I can't use ST_ClosestPoint function and I have to use ST_Distance function and get the min(ST_distance) record but I am quite stuck building the query.  CREATE TABLE traffic_signs (   id numeric(8,0) ),   "GEOMETRY" geometry,   CONSTRAINT traffic_signs_pkey PRIMARY KEY (id),   CONSTRAINT traffic_signs_id_key UNIQUE (id) ) WITH (   OIDS=TRUE );  CREATE TABLE entrance_halls (   id numeric(8,0) ),   "GEOMETRY" geometry,   CONSTRAINT entrance_halls_pkey PRIMARY KEY (id),   CONSTRAINT entrance_halls_id_key UNIQUE (id) ) WITH (   OIDS=TRUE );   I need to obtain the id of the closest entrnce_hall of every traffic_sign.  My query so far:  SELECT senal.id,port.id,ST_Distance(port."GEOMETRY",senal."GEOMETRY")  as dist     FROM traffic_signs As senal, entrance_halls As port        ORDER BY senal.id,port.id,ST_Distance(port."GEOMETRY",senal."GEOMETRY")   With this I am getting the distance from every traffic_sign to every entrance_hall. But how can I get only the minimun distance?  Regards, Why AUC =1 even classifier has misclassified half of the samples? Square root of 1 is (not) -1 Possible Duplicate:          I was thinking on the following line of thoughts: $1 =  \sqrt{1} = \sqrt{-1 \cdot -1} = \sqrt{-1} \cdot \sqrt{-1} = i^2 = -1$  Of course this is not true, but I was wondering which step in this 'line of thoughts' is forbidden to make?   Thanks for the explanation. Can I define keyboard shortcuts using the Super key? DOS of Van Hove singularity in 2D square lattice tight binding model For the simplest example, 2D square lattice tight binding model gives the energy band as $$\varepsilon_k=-2t(\cos k_x+\cos k_y) \, .$$ We know that $\mathbf{k}=(0,\pi)$ and related momentum points are saddle points which give $|\nabla_k \varepsilon_k|=0$ and thus some kind of singularity in density of state (DOS) since $$\rho(\varepsilon)\propto \int_{\varepsilon=\text{const}} \frac{d S}{|\nabla_k \varepsilon_k|} \, .$$ How can I get the $\ln$ divergence for DOS near $\varepsilon=0$? Should I only care about those singularity points and omit the integral from normal parts and do Taylor expansion near those saddle points?   Moreover, why are points like $(\pi/2,-\pi/2)$ or $(2\pi/3,-\pi/3)$ not called Van Hove points when those points are also lie in the $\varepsilon=0$ line and give $|\nabla_k \varepsilon_k|=0$? When an option expires does that constitute a buy or sell A similar question recently asked about stock sales and option buys triggering wash sale rules.  If an option expires, is that considered a buy/sale ?  What I mean is: let's assume I have a call option with a target date of August 16. Now I sell the underlying stock somewhere before that (after July 16th). Does that trigger wash sale rules (if the option expires in the money, exercised by default) ?  Is an option expiring out of the money considered a sale ? Is time dilation an illusion? How could it be that the entropy of gas is not infinite?  If we use the formula $S=k\ln(\Omega)$ we get infinity because there are an infinite number of possible situations (because there are infinite possibilities of position and momentum for each molecule). Why is spectrum obtained by sunlight, said to be continuous? My teacher spoke about atomic spectra today, and he explained that, unlike the spectrum obtained by analyzing the sunlight, the spectra of atoms are not continuous.     I have a question about this - even the sunlight has the radiations emitted by the atoms of the elements which compose the sun, still spectra is continuous, which is in opposition to the statement that atomic spectra is discontinuous. So, spectrum obtained by sunlight is continuous even though it atomic spectra. In order to account for spectrum obtained by the sunlight to be continuous and atomic spectra to be discontinuous, can we confirm that sun consists of all those elements (sodium, helium, neon, mercury, etc) which emit the colors of frequency belonging to visible region? Is $\le$ defined by $\langle 𝑥_1, 𝑦_1 \rangle \le \langle 𝑥_2, 𝑦_2 \rangle$, if $𝑥_1 \le 𝑥_2 \land𝑦_1 \ge 𝑦_2$ a linear order? I need to tell if the relation $\le$ defined by relationship $\langle 𝑥_1, 𝑦_1 \rangle \le \langle 𝑥_2, 𝑦_2 \rangle$, if $𝑥_1 \le 𝑥_2$ $\land$ $𝑦_1 \ge 𝑦_2$ linear order?   I have already proven that the relation is an order, but I need to decide if it is a linear order and why. Thanks for any help! Why am I not burned by a strong wind? Countability of disjoint intervals According this problem/solution set from an MIT class (http://ocw.mit.edu/courses/mathematics/18-100c-analysis-i-spring-2006/exams/exam1_sol.pdf), the assertion:  "Every collection of disjoint intervals in R is countable."  is True, because "every interval contains a rational number", and the rationals are countable.  It seems to me this should be False, with possible counterexample:  { [x,x] | x is an element of R}  ie the set of all singelton intervals on R. Why isn't this a valid counterexample?