In C language I am trying to assign a value to pointer string. I cannot use char array, I have to use pointer string. So please tell how can I do that?  I am doing something like this (code given), but when I run my code an error is prompted program stopped working.  #include &lt;stdio.h&gt;   int main (void) {      char *myString = " ";     int value = 1;      myString[0] = value+'0';      printf("%s\n",myString);      return 0; }
The following code receives seg fault on line 2:  char *str = "string"; str[0] = 'z';  // could be also written as *str = 'z' printf("%s\n", str);   While this works perfectly well:  char str[] = "string"; str[0] = 'z'; printf("%s\n", str);   Tested with MSVC and GCC.
Do film industries outside India use intervals/Intermission? A man enters a comatose author's dreams to wake him up This is a short story, I think, but I might be wrong.  A man is recruited to enter an authors' dreams to try &amp; bring him out of a coma &amp; finds himself in a hackneyed barsoom type world where the coma victim is a muscle bound hero, it's a desert world with two suns, the damsel in distress is the typical scantily clad princess trope.  The "hero" basically spoils the authors' dreams by manifesting a pistol &amp; simply shooting the monsters dead at one point &amp; the author tries to write him out of the "story" by simply jumping forward several chapters &amp; is both surprised &amp; peeved to find him still there.  The author eventually comes out of his coma &amp; immediately assaults the man when he recognizes him from his dreams, he tries to strangle him if I remember right.  He enters the authors' dreams with some kind of experimental dream imaging tech, basically a two ECG sort of set up linked through a computer with him put to sleep with drugs I think. Singular verb after two noun phrases joined by "and" that can be thought of as a single thing Prove that if $a \mid b$ then $\gcd(a,b) = |a|$ pgfmathanglebetweenpoints always returns 90 Show that $d_b(x,y)=\frac{d(x,y)}{1+d(x,y)}$ is a metric. where $(X,d)$ is a metric and $x,y \in X$.  I know we need to show:   non-negativity: $d(x,y)\geq$ 0 $d(x,y)=0$ if and only if $x=y$ symmetry: $d(x,y)=d(y,x)$ $d(x,z)\leq d(x,y) + d(y,z)$   I think we need to consider the derivative of $f(t)=\frac{t}{1+t}$ however I am not sure what to do next. I use Cygwin on my laptop (DOS). I have a collection of scripts from my colleagues, and my own. I am not an IT person, not knowledgeable in Unix. I am following my colleagues' syntax and able to manage a few simple things. The scripts worked well on my old laptop. I just changed laptop and installed Cygwin. When I run my scripts, they do not work. Here is one example of the error message I get: line 1: $':\r': command not found line 5: syntax error near unexpected token `$'\r'' line 5: `fi  Here are the top 5 lines of my script : iter=1 if [ -f iter.txt ]    then rm ./iter.txt  fi    Can someone please explain how I can get around this problem? Indicate How Trustworthy the UpVotes Are Proof of an equality involving cosine $\sqrt{2 + \sqrt{2 + \cdots + \sqrt{2 + \sqrt{2}}}}\ =\ 2\cos (\pi/2^{n+1})$ so I stumbled upon this equation/formula, and I have no idea how to prove it. I don't know how should I approach it: $$ \sqrt{2 + \sqrt{2 + \cdots + \sqrt{2 + \sqrt{\vphantom{\large A}2\,}\,}\,}\,}\ =\ 2\cos\left(\vphantom{\Large A}\pi \over 2^{n + 1}\right) $$  where $n\in\mathbb N$ and the square root sign appears $n$-times.  I thought about using sequences and limits, to express the LHS as a recurrence relation but I didn't get anywhere.  edit: Solved, thanks for your answers and comments. What is the difference between a static and a non-static initialization code block My question is about one particular usage of static keyword. It is possible to use static keyword to cover a code block within a class which does not belong to any function. For example following code compiles:  public class Test {     private static final int a;         static {         a = 5;         doSomething(a);     }     private static int doSomething(int x) {         return (x+5);     } }   If you remove the static keyword it complains because the variable a is final. However it is possible to remove both final and static keywords and make it compile.   It is confusing for me in both ways. How am I supposed to have a code section that does not belong to any method? How is it possible to invoke it? In general, what is the purpose of this usage? Or better, where can I find documentation about this? Stopping Dwarf Fortress from auto-pausing Is it possible to prevent DF from pausing every time something comes up (liking hitting gold or whatever). The reason is that I am doing extensive mining and I want to leave the process unattended till it is over. Name of component on output side cable of a DC power adapter? Brownian motion - Hölder continuity Let $B$ stand for a Brownian motion on a finite interval $[0,1]$. If I am not wrong, I think that there exists a positive constant $c$, such that almost surely, for $h$ small enough , for all $0&lt; t &lt; 1- h$  \begin{align} |B(t+h)-B(t)| &lt; c\sqrt{h\log(1/h)} \end{align} or something like this. As a result   \begin{align} \bigg|\frac{B(t+h)-B(t)}{h}\bigg| &lt; K(h)  \end{align}  Am I correct ? A formal name for "smallest" and "largest" partition Consider a set $A=\{1,2,3,4,5\}$, is there any terminology for the following partitions of $A$ ?  (1) $A=\{ \{1\},\{2\},\{3\},\{4\},\{5\} \}$  (2) $A=\{\{1,2,3,4,5\}\}$. How to find normal and lognormal moments, given partial information? $Y=\ln(X)$. $X$ is lognormal and $Y$ is normal. If all I know is the arithmetic mean of $Y$ and the standard deviation of $X$. What is the formula to calculate the arithmetic mean of $X$ and the standard deviation of $Y$? What is Uplay? Can I play Ubisoft games without it? Heroes of Might and Magic VI seems to have installed a program called "Uplay", which it uses to launch (in addition to Steam, mind!)  What exactly is Uplay supposed to be? I notice that when I stop playing, it captchalogs the highlights of my past session (achievements earned, etc.) - which is kinda cool, but also kinda creepy and big-brotherish. Given that I value my privacy, is there anyway to play Uplay games without using Uplay?  Is this just Ubisoft's infamous "always-on" DRM? Is adjoint of singular matrix singular? What would be its rank? At some point in time (about a week ago) something happened to my Motorola Moto Z2 Play / Android 8.0 that caused my base apps to not have access to my media files (i.e. audio, photos etc.). Examples:  all my custom ringtones (i.e. based on my own media files) were reset to default sound:  Contact apps reset custom ringtones for contacts to default one, Alarms &amp; Clock app reset custom alarm tone to default one, SMS (Messages) app reset custom message notification tone to default one, system-wide default notification tone (set by me to custom) was reset as well, system-wide default ringtone (set by me to custom one) was reset,    because my contacts app keeps saying: &quot;No pictures are available on the device&quot;.  While first situation is resolved. I see my custom ringtone files in the list and I can go through my contacts and assign them again. But second situation is not resolved. I see this error all the time and I cannot change any contact's photo. This is verified as not a bug (tested three different contacts-like applications and all of them shows exactly the same message, when trying to change contact's photo). But still, it seems that problem is limited to contacts-related apps only. Other apps still has read and write access to my custom files. For example: :  (read) I can pick any photo or other custom file and attach it to an e-mail, send it as MMS or share it in any other way or (read) upload it to OneDrive or Google Drive etc. or (write) my Camera app is still able to make new photos and store them in &quot;DCIM&quot; or (write) my sound recorder is able to record sound and write audio files.  The only thing that has changed on my phone recently and that I suspect as the cause of above metioned situation was Android 7.1.2 --&gt; Android 8.0.0 update. Is there anything I can do (since replacing contacts app didn't resolve the situation) or check in this case? Or resetting the phone to factory defaults is the only option that I am left with? EDIT: I have cleared cache and data of media app, as suggested in comment. It didn't help. Finding cartesian product with PHP associative arrays Currently the migration path options from SO are:   Meta.SO Serverfault SuperUser Webmasters Programmers   If we are going to be limited to 5 options, shouldn't we periodically re-evaluate which sites are most appropriate?   (10k only) indicate that the top sites for the last 90 days are:   Superuser - 564 - 5% rejected ServerFault - 278 - 10% rejected Tex - 157 - 13% rejected DBA - 144 - 2% rejected Sharepoint - 127 - 1% rejected Programmers - 126 - 26% rejected CodeReview - 100 - 3% rejected Meta.SO - 81 - 18% rejected Wordpress - 75 - 14% rejected Webmasters - 58 - 8% rejected   All these migrations for sites out of the list required a flag and a moderator to process it.  This is just extra work for the mod team!  If we had the top 5 destinations by volume as the 5 options, we would have had a net savings of 160 flags to be processed.  I suspect we will actually see these numbers change quite a bit if it's easier for users to put questions in the appropriate spot without moderator intervention.  Can we have a review of the migration path list based on migration volume?  Think of the flags!