I was trying out a sample program to understand about the generic swap function.  /* A simple generic swap function */  #include&lt;stdio.h&gt; #include&lt;string.h&gt;  void swap(void* xp,void* yp,int size){         //void temp = *xp; // we cant declare a variable as void , as we need to konw to de-reference as its not specifying any size info         // Hence used the smallest type info - char         char buffer[size];         memcpy(buffer,xp,size);         memcpy(xp,yp,size);         memcpy(yp,buffer,size); }  int main(){         int a = 10;         int b = 20;         double d=1.34;         double e=2.34;         char* s = "Hello";         char* t = "World";         printf("\n a : %s b : %s \n",s,t);         swap(s,t,sizeof(char*));         printf("\n a : %s b : %s \n",s,t);         return 0; }   I got a segmentation fault when I ran the above program with the function call as swap(s,t,sizeof(char*)). But if I run it with swap(&amp;s,&amp;t,sizeof(char*)), I don't get any segmentation fault.  gdb o/p:  Breakpoint 2, swap (xp=0x4007ac, yp=0x4007b2, size=8) at swap_generic1.c:5 5   void swap(void* xp,void* yp,int size){ (gdb) s 8       char buffer[size]; (gdb) s 9       memcpy(buffer,xp,size); (gdb) s 10      memcpy(xp,yp,size); (gdb) s  Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7b64fe4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6   what might be the cause of the problem. Is that when passed as s and t, the argument is assigned with the address of the strings "Hello" and "World" respectively, and the pointer increments goes sto some other location to fetch the values.
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.
How can I view all of the flights between two cities across all dates? I believe that the standard routes of carriers between two semi-major US cities always maintain the same route number (e.g. UA3271), and day of the week. I'm looking at planning travel for an interview, so dates are [currently] quite flexible (as in at least one month's range). Since that's the case, there are other constraints that go into my choice of flights. One would be the option to fly out of my home city, land in the interview location, conduct the interview, and fly out in the same day. I figure: if I can view the schedule for flights (i.e. routes) between the two cities, I can make an educated request for days of travel. Yes, I could likely work with the interview scheduler (and I will), but I'd like to be proactive in suggesting some dates to achieve my goal, as well as learn this skill for myself in the future. Thus:  Where can I view the daily routes and times for flights between two cities, on whatever rotating basis (e.g. day of the week) they may be on? PrintWriter and PrintStream never throw IOExceptions Some days ago I realized that  (as well as ) never throw an IOException when writing, flushing or closing.  Instead it sets an internal flag (trouble=true) when an error occurs. It's not possible to get the exact exception, but only if there was some exception ().  My question is: why would one want to have such behavior? Isn't that bad API design? Why is the decay of a neutral rho meson into two neutral pions forbidden? Why did the snake wink at Harry at the zoo? This is mostly a memory question - I'm having a hard time remembering this and I can't read the book right now.  On the first book, a snake at the zoo winks at Harry. For the sake of the question, we'll assume that snakes can in fact wink.  I have a fuzzy memory here - I think that it winked before Harry had any kind of interaction with the snake (was this before or after Harry broke the glass?)  So, why did the snake wink at Harry? Given that they had not met ever before.  I suppose that the only reason it would wink at Harry would be because it knows Harry can communicate with it. But this would imply that snakes are capable of sensing such ability on wizards - is there (other) evidence that this is true? Why does magnet attract iron but not other metals? How do I make my program watch for file modification in C++? Is it possible to view Google Chrome bookmarks and history from the terminal Is it possible to view Google Chrome bookmarks and history by using command line? An inequality involving 4 real or complex numbers I'm trying to access an XML file within a jar file, from a separate jar that's running as a desktop application.  I can get the URL to the file I need, but when I pass that to a FileReader (as a String) I get a FileNotFoundException saying "The file name, directory name, or volume label syntax is incorrect."  As a point of reference, I have no trouble reading image resources from the same jar, passing the URL to an ImageIcon constructor.  This seems to indicate that the method I'm using to get the URL is correct.  URL url = getClass().getResource("/xxx/xxx/xxx/services.xml"); ServicesLoader jsl = new ServicesLoader( url.toString() );   Inside the ServicesLoader class I have   XMLReader xr = XMLReaderFactory.createXMLReader(); xr.setContentHandler( this ); xr.setErrorHandler( this ); xr.parse( new InputSource( new FileReader( filename )));   What's wrong with using this technique to read the XML file? Rights if we possess Carta di Soggiorno? I have searched the internet but could not find specific information so if we have got the following document "Carta di Soggiorno di Familiare di Un Cittadino Dell'Unione" (Residence Card of a family member of a Union Citizen, Italy) issued by the Italian authority, what rights do we possess of working inside Italy and EU? What about travelling? Will we be requiring visas for the states which are are not in Schengen? Handling registration ID changes in Google Cloud Messaging on Android Does MariaDB or MySQL implement the VALUES (expression) table value constructor? I'm using Drupal 7.  Is it possible to add a CC to a webform email?  I was using   function theme_webform_mail_headers($variables) {   $headers = array(     'X-Mailer' =&gt; 'Drupal Webform (PHP/' . phpversion() . ')',   );   return $headers; }   changing it with      function MYTHEME_webform_mail_headers($variables) {       $headers = array( 'CC' =&gt; 'ccmeail@domain.com', 'X-Mailer' =&gt; 'Drupal Webform (PHP/'. phpversion() .')',  );       return $headers;     }   It does not work, I've cleared all the chaches and it does not add the CC. How could I add the CC?  Thanks in advance. Building a wormhole We regularly get questions about wormholes on this site. See for example  and . Various wormhole solutions are known, of which my favourite is  because it's closest to what every schoolboy (including myself many decades ago) thinks of as the archetypal wormhole.  The trouble is that Visser has pulled the same trick as  of starting with the required (local) geometry and working out what stress-energy tensor is required to create it. So Visser can tell us that if we arrange exotic string along the edges of a cube the spacetime geometry will locally look like a wormhole, but we know nothing about what two regions of spacetime are connected.  My question is this: suppose I construct a Visser wormhole by starting in Minkowksi spacetime with arbitrarily low densities of exotic matter and gradually assembling them into the edges of a cube, how would the spacetime curvature evolve as I did so?  I'm guessing that I would end up with something like Wheeler's bag of gold spacetime. So even though I would locally have something that looked like a wormhole it wouldn't lead anywhere interesting - just to the inside of the bag. I'm also guessing that my question has no answer because it's too hard to do any remotely rigorous calculation. Still, if anyone does know of such calculations or can point me to references I would be most interested. The roots of the equation $z^n=(1+z)^n$... The complex roots of the equation      $$z^{n}=(1+z)^{n}$$   $A.$ are vertices of a regular polygon  $B.$ lie on a circle  $C.$ are collinear  $D.$ none of these  Don't know where to start.. Please help.!  NOTE:  $z$ is a complex number. Word for one who likes to share knowledge when asked Is redirecting homepage to a page with keyword it's targeting helps in SEO? #!/bin/bash - no such file or directory I've created a bash script but when I try to execute it, I get   #!/bin/bash no such file or directory   I need to run the command: bash script.sh for it to work.  How can I fix this? How to insert a very large number of records into a MySql database as fast as possible $f$ is surjective iff it has a right inverse: using the axiom of choice and errors in ProofWiki