The following case makes more confuse to me. As far as I know, local variables don't return  by pointers or reference. for example   char * foo() {   return "Hello world"; }  int*  fooo() {     static int i = 100;     return &amp;i; }   What would happen in both cases ?
I'm working with some code that widely uses the idiom of returning a pointer to a static local variable.  eg:  char* const GetString() {   static char sTest[5];   strcpy(sTest, "Test");   return sTest; }   Am I right in thinking that this is safe?  PS, I know that this would be a better way of doing the same thing:  char* const GetString() {   return "Test"; }   Edit: Apologies, the function signature should of course be:  const char* GetString();
Is there a kind of microdata or markup that creates "results x of y" in search results When it's OK to omit "where?" Windows 7 unidentified network (or limited access) after hibernate My windows 7 network will show limited access or unidentified network after coming up from hibernation.  In the office I normally use LAN connection, I turn-off my wireless card (DELL Latitude has on/off switch for the wireless card). When I back at home I will turn on the wireless card, but it will take about 15 seconds to detect my home WIFI and then show limited access. I will have to restart the notebook and it will be able to connect to my WIFI and internet.  The problem will be solved if I restart the notebook, but that defeats the purpose of hibernation doesn't it?  I have tried uninstalling the wireless card driver but still does not solve it. I also tried updating my network card driver but windows says I am using the latest driver. On support.dell.com also showing I am using the latest driver. How does Windows know whether it has internet access or if a Wi-Fi connection requires in-browser authentication? In Windows 7, the notification area networking icon will show an error indicator if there is no internet access , and the error icon goes away once there is a successful connection to the internet . Sometimes, if the WiFi connection requires an in-browser authentication step, like on many guest networks in hotels or universities, then the following pop-up bubble appears, saying as much:    How does Windows know whether or not it has a successful internet connection? Presumably it is checking some online Microsoft service to see whether it has a successful connection, gets redirected to some other page, or doesn't get any response at all, but I haven't seen anywhere that this process or the services used are documented. Can anybody explain how this works? I would prefer answers that refer to facts, rather than just guessing, but if you have a really good guess, then go for it.     This question was a .   Read the May 16th, 2011  for more details or  Question of the Week. Can I use extra wire from two separate cables to add a washing machine in a garage? Re-Structuring a JSON Does the output bypass capacitor of an LM7805 double as a decoupling capacitor? I'm using a 5v linear regulator (specifically an LM7805) that outputs directly to an ATMEGA328P. According to the  (page 23) input and output bypass capacitors should be used, as seen below, to tame peaks and ensure stability.    It is good practice to also include a decoupling capacitor in front of an IC, in this case an ATMEGA328. Does the 0.1μF capacitor on the output side of the LM7805 act as a decoupling capacitor if the regulator feeds into the IC directly after the output bypass capacitor? Getting the ID of the element that fired an event How does the speed of electrons change around a circuit? I have been thinking about ways of teaching electronics and I'm wondering if the following is true...  For starters, when we talk about voltage as energy per unit charge, is this energy manifest simply as the kinetic energy of the electron?  So, all other things being equal, will the electrons coming out of a 4 volt battery will have twice the velocity of electrons coming out of a 1 volt battery because of ${1 \over 2}mv^2$?  This would seem to imply that the voltage drop across different parts of the circuit is essentially a comparison of the electron speeds at those points.  Furthermore doesn't this imply that the electrons are nearly halted by the time they reach the positive terminal of the battery? This makes intuitive sense to me, it seems pedagogically sound, and it provides an explanation for how electrons "know" to give up their energy across the circuit -- electrostatic repulsion communicates later resistances to earlier parts of the circuit.  How much of the above is correct? The one things that makes me suspicious is that, in this picture, electron density at the positive terminal of the battery is very high, and repulsive forces would prohibit this. On the other hand, if the Joules per Coulomb are not coming from kinetic energy, then what? The field? But wouldn't that just dissipate as light?  Something is wrong but I don't know what. I need a counsel about my websites' domain.  Let's say I have just bought two domains: xyz.com and xyzphotography.com.  As we can see, the first one is shorter but way less meaningful than the second one. The second one contains a photography keyword but it's longer.  I have only one website which is my photography portfolio. Can you advise me how to set those domains to make it all as SEO-friendly as possible? Which one should be the main one, does the rest should work on their own or have some kind of SEO-friendly redirect to the main domain? Does black hole formation contradict the Pauli exclusion principle? A star's collapse can be halted by the  due to the Pauli exclusion principle. In extreme relativistic conditions, a star will continue to collapse regardless of the degeneracy pressure to form a black hole. Does this violate the Pauli exclusion principle? If so, are theorists ok with that? And if it doesn't violate the Pauli exclusion principle, why not? I need to run a query like:  SELECT p.id, p.name,         (SELECT name            FROM sites s           WHERE s.id = p.site_id) AS site_list   FROM publications p   But I'd like the sub-select to return a comma separated list, instead of a column of data.  Is this even possible, and if so, how? How do I check if an object has a specific property in JavaScript? How do I check if an object has a specific property in JavaScript?  Consider:  x = {'key': 1}; if ( x.hasOwnProperty('key') ) {     //Do this }   Is that the best way to do it? Why doesn't calling a Python string method do anything unless you assign its output? Find the general solution of $xy''-(1+x)y'+y=x^2$ knowing that the homogeneous equation has the following solution: $e^{ax}$, where $a$ is a parameter you have to find.  I have found that $a=1$ or $a=1/x$. An example of a sequence of Riemann integrable functions $(f_n)$ that converges pointwise to a function $f$ that is not Riemann integrable. I have been given the example $$ f_n(x)= \begin{cases} 1, &amp; \text{if}\; x\in\{(x_k)_{k=1}^{n}\}, \\ 0, &amp; \text{otherwise.} \end{cases} $$ Here the sequence $(x_k)_{k=1}^{\infty}$ is the sequence that "enumerates" elements of $\mathbb{Q}$. The sequence of functions converges pointwise to $$ f(x)= \begin{cases} 1, &amp; x\in\mathbb{Q}, \\ 0, &amp; x\notin\mathbb{Q}, \end{cases} $$ which isn't Riemann integrable. However, I am not quite convinced that $f_n$ is integrable. I would like some help in seeing how $f_n$ is Riemann integrable. Also, I would like more examples of sequences of Riemann integrable functions $f_n$  that converge pointwise to a function $f$ that is not Riemann integrable. Perhaps this is trivial: how does one prove that the work done by a homogeneous gravitational field on a system of particles is equal to the work done on a point mass with the total mass of the system, located at the center of mass of the system. A sci-fi book or TV show about a tribesman discovering he or she actually lives in a huge spaceship The story starts with a tribesman going on a exploratory voyage around the land, meeting other progressively more and more distant tribes, learning about the world. Gradually he or she discovers that the "world" is actually a giant spaceship flying through space.  The story climaxes by the hero ascending to the commanding deck and learning who actually pilots the ship and to what purpose. I have two given names and one surname. Is it a problem if I omit the surname from my ticket? I have two names as my given name in the passport and I typically just use this as my first and last name. However, my passport has a surname too which I almost never use. Due to this, I mistakenly provided my given name as first and last name.   As per the passport,  Surname : AAAA Given name(s) : BBBB CCCC   In the ticket, First name : BBBB Last name : CCCC  The credit card I've used to make this booking has my name as BBBB CCCC.  Will this create a problem at the travel time?  Update : the airline says that they can't update the name in the ticket. They are saying that since they have made a remark of the passport details boarding will not be a problem but I might face problems at immigration. Do they check name details in itenerary to exactly match passport at the time of immigration? Is that true in your experience?  Update : Travelled without any problem, neither at boarding gate, immigration nor after arrival at border police control. Difference between float and decimal data type