I am having a difficult time obtaining the correct size of a string in order to satisfy strcpy_s.   For example if I specify  char buffer = {0}; char *str1 = (char*)&amp;buffer;     strcpy_s(str1,sizeof("This is a string\n"),"This is a string\n");   Then it will work as expected.   If however I declare the following:  char buffer = {0}; char *str1 = (char*)&amp;buffer; const char* string1 = "This is a string....."; strcpy_s(str1, ?????,string1);   If I use anything other than a literal in place of ????? it will fail with a memory exception, for example if I use std:strlen(str1), etc.  Any size literal for ???? will work.   Of course using a fixed literal is not acceptable.  This is a major re-edit of the original question and I apologise to the people who have answered to date.   However none of the the answers below have worked.
First off, here is some code:  int main()  {     int days[] = {1,2,3,4,5};     int *ptr = days;     printf("%u\n", sizeof(days));     printf("%u\n", sizeof(ptr));      return 0; }   Is there a way to find out the size of the array that ptr is pointing to (instead of just giving its size, which is four bytes on a 32-bit system)?
What do you call someone who has extensive knowledge but won't share it? What can I use to typeset MATLAB code in my document? This question led to a new package:      Does anybody have a quick and easy way to typeset some relatively long MATLAB code in the appendix? I looked up a few methods, and the mcode package emerged as a possibility, but it seems to be unmaintained...  I have a ton of equations in my code, so I'd prefer a solution that avoids having to use $ to denote equations.  Also, if possible, if there's a way to keep all of MATLAB's "natural" coding colors (e.g. green for comments), that would be great...  Any idea? Help with proving that $\pi$ is irrational I was trying to prove that $\pi$ is irrational, just to see if I could do it. So far, I've tried to do this by using the fact that the sum   $$S=\sum\limits_{k=1}^\infty \frac{1}{k^2}=\frac{\pi^2}{6}$$ and arguing that $S$ is irrational instead, and thus implying that $\pi$ is also irrational.  To do this, I thought I could use partial sums $S_n$ of $S$:  $$S_n=\sum\limits_{k=1}^n \frac{1}{k^2}=\frac{A_n}{B_n}$$ where the fraction $A_n/B_n$ is written in lowest terms. We can note that the sequence $\lbrace S_n \rbrace$ is a strictly increasing sequence, with $\pi^2/6$ as its lowest upper bound, so I thought that maybe the sequences $\lbrace A_n \rbrace$ and $\lbrace B_n \rbrace$ both have no upper bound, and the sequences would tend to infinity, and if I were able to prove this, I thought I could use it to argue that $S$ is an irrational number, using the fact that every rational number can be written as the quotient between two finite integers.  We note that $A_n\geq B_n$ for all natural $n$, as $S_n\geq 1$, so all we would really need to prove in that case is that $\lbrace B_n \rbrace \rightarrow \infty$(if this assertion is even correct).  At first I thought that both $\lbrace A_n \rbrace$ and $\lbrace B_n \rbrace$ would be increasing sequences, but after checking with Maple I noticed that they weren't, sadly enough($S_9=\frac{9778141}{6350400}$ and $S_{10}=\frac{1968329}{1270080}$). However, they do indeed seem to get very large very quickly, so I'm thinking that my hypothesis about $\lbrace A_n \rbrace$ and $\lbrace B_n \rbrace$ is correct.  But I have trouble proving my hypothesis, and I'm kind of stuck, no knowing what to do. Is there a way to prove that $\lbrace B_n \rbrace \rightarrow \infty$? And of course, is this approach to prove that $\pi$ is irrational logically sound, or is it fundamentally flawed in some important aspect? In the latter case, what idea should I try next? How to insert text into a root-owned file using sudo? Characterising reals with terminating decimal expansions Show that a number has a terminating decimal expansion if and only if, it is rational and when in lowest terms, its denominator is coprime to all primes other than $2$ and $5$.   This is an unsolved question in my lecture notes. I can only seem to prove the converse direction for this. Would appreciate a solution for the other direction.     For converse direction:   Let the number, in lowest terms, be given by $\frac{l}{m}$ where $m = 2^ \alpha 5^\beta$, for some positive integers, $\alpha$ and $\beta$.    If $\alpha &gt; \beta$, let $k = 5^{(\alpha-\beta)}$. If $\alpha &lt; \beta$, let $k = 2^{(\beta-\alpha)}$.   Then $\frac{l}{m} = \frac{kl}{k2^\alpha5^\beta}=\frac{kl}{10^q}$ where $q = \max(\alpha,\beta)$.   Hence $\frac{l}{m}$ is a terminating decimal. Calculate work done by a hovering helicopter over time This is likely to be very simple, but...  How does one calculate work done by a hovering unmoving aircraft over time?  As in work in Joules.  In this scenario, to remain hovering the aircraft has to exert a force that counters gravity (which would be its mass times G, pointing in opposite direction of gravitational pull).  However, work is defined as newton per meter, and the aircraft does not move.  Meanwhile the battery charge or fuel is going to be expended, so the energy is spent.  The other question here:   is dealing with conservation energy and not calculating drain/work performed by hovering. How to create animated GIF images of a screencast? I've seen animated GIF images of screen casts (like the one below) promoted a few times on this site as a way to improve answers.    What toolchain is being used to create these? Is there a program that does this automagically, or are people taking screencasts, converting them into a series of static frames, and then creating the GIF images? URL regex passed by regex buddy but failed by Dart Linearization of PDE: $0$ is an eigenvalue since all translates of travelling waves are also travelling waves Consider the following PDE: $$ u_t=u_{xx}+f(u)-w,~~~~~w_t=\varepsilon (u-\gamma w),~~~~~~~~~(1) $$ where $f(u)=u(u-a)(1-u), 0&lt;a&lt;\frac{1}{2}, \varepsilon,\gamma &gt;0, \varepsilon\ll 1,\gamma\ll 1$.  A travelling wave for (1) is a solution that is a function of the single variable $\xi=x-ct$, i.e., $(u(\xi),w(\xi))$ satisfies $$ -cu'=u''+f(u)-w,~~~~~~-cw'=\varepsilon (u-\gamma w)~~~~~~~('=d/d\xi).~~~~~~(2) $$  If (1) is recast in a moving coordinate frame, i.e., in terms of variables $\xi=x-ct$ and $t$, it becomes $$ u_t=u_{\xi\xi}+cu_{\xi}+f(u)-w,~~~~~~w_t=cw_{\xi}+\varepsilon (u-\gamma w).~~~~~~~~(3) $$  One can see by (2), that a travelling wave is an equilibrium solution of (3). So one nearby question is to ask whether a travelling wave is stable.    For a fixed $\varepsilon$, let $U_{\varepsilon}(\xi)=(u_{\varepsilon}(\xi),w_{\varepsilon}(\xi))$ be a travelling wave for (1), i.e., an equilibrium solution for (3).          A standard technique for determining stability of $U_{\varepsilon}(\xi)$ is to linearize: If the right-hand side of (3) is linearized along $U_{\varepsilon}(\xi)$, the resulting operator is     $$ L\begin{pmatrix}p\\r\end{pmatrix}=\begin{pmatrix}p_{\xi\xi}+cp_{\xi}+f'(u_{\varepsilon})p-r\\cr_{\xi}+\varepsilon (p-\gamma r)\end{pmatrix}, $$     where $\begin{pmatrix}p\\r\end{pmatrix}(\xi)\in\text{BC}(\mathbb{R},\mathbb{R}^2):=\left\{u\colon\mathbb{R}\to\mathbb{R}^2 | u\text{ is bounded and uniformly continuous}\right\}$.      (The linearized criterion for stability of the travelling wave is that the spectrum of $L$ (except for $0$) lies in a left half-plane and $0$ is a simple eigenvalue.)  Thats the background.  Now, there is a statement that I could not understand yet.          Note, that $0$ must be in the spectrum because the translate of a travelling wave is another travelling wave.      I know that a translate of a travelling wave is again a travelling wave. But why does this imply that $0$ is in the spectrum of $L$?  Edit  After some looks at definitions, I have an idea:  Consider a solution $U(\xi,t)$ that is a translate of the travelling wave $U_{\varepsilon}(\xi)=(u_{\varepsilon}(\xi),w_{\varepsilon}(\xi))$, i.e.  $$ U(\xi,t)=U_{\varepsilon}(\xi-k)=(u_{\varepsilon}(\xi-k),w_{\varepsilon}(\xi -k)) $$ for some $k$. Then $U$ is an equilibrium solution of (3), too.  If I am not totally wrong, then we have  $$ p=u_{\varepsilon}(\xi-k)-u_{\varepsilon}(\xi),~~~~r=w_{\varepsilon}(\xi-k)-w_{\varepsilon}(\xi) $$ and  $$ p_t=0,~~~w_t=0, $$ because travelling waves are equilibria for (3) and a translate of a travelling wave is a travelling wave.  Hence $$ L\begin{pmatrix}p\\r\end{pmatrix}=\begin{pmatrix}0\\0\end{pmatrix}, $$ meaning that $$ \text{ker}(L-0\text{ id })\neq\left\{\begin{pmatrix}0\\0\end{pmatrix}\right\}, $$ because for each translate of the travelling wave, $p,r\neq 0$ and  $\begin{pmatrix}p\\r\end{pmatrix}\in\text{ker}(L-0\text{ id})$.  Hence $0$ is in the spectrum (point spectrum) of $L$.  Is this what was meant? Is there an GUI Designer for python? I have a long-running Python server and would like to be able to upgrade a service without restarting the server. What's the best way do do this?  if foo.py has changed:     unimport foo  &lt;-- How do I do this?     import foo     myfoo = foo.Foo() At the end of every day you will be required to write a review.   At the end of each day you will be required to write a review.   Which one of those sentences is better if this action will repeat itself every day for longer period of time, several weeks for example, maybe even months? Merge two custom post types into one admin page? I am building a site with 4 custom post types. To make things easier for our client/admin, I'm wondering if there is a way to merge those custom post types into one list in the backend? Like if you look at normal backend admin page with the list and columns of posts, can a page like that pull in 3 other post types for easy sorting/searching?  I can't combine the CPTs into one, they must remain seperate outside of one 'viewing' page in the admin area if possible.  Any thoughts on how to do this?? Or even where to start looking/thinkging of how to develop this? Creating a gradient-based legend I have a map with graduated symbology, with 328 unique values. I would like to add a legend to my map (as in the picture), illustrating that light blue indicates low values and dark blue high values.  I have done this in ArcGIS before. Is there a way to do this in QGIS as well? How can I make threading more flexible? Connectedness of the Hausdorff distance. Does anyone know a proof of connectedness of the Hausdorff distance?  I mean a proof of the following:  Theorem  If $(X, \rho )$ is a connected metric space, then $(F(X), d_h )$ is also connected.  Remark:  $F(X) = \{ A \subseteq X | A \text{ is nonempty, closed and bounded } \} $, and $d_h$ stands for the Hausdorff distance. Prove that for any square matrix, an invertible matrix B exists, so that BA is triangular I'm given a matrix A, its dimensions are n x n.  I am required to prove that an invertible matrix B exists, such that the product of the matrices BA is triangular.  Any help? Projectile/orbital motion over very long distance We know the optimum angle for greatest horizontal displacement when launching an object with projectile motion is 45 degrees.  How to solve the angle when it is real long distance around the earth where we cannot assume that gravity is constant but is given by $F=\frac {-GMm}{r^2}$. I use differetial equation to solve it and obtain 45 degrees.   First, for the vertical distance $y$, change $v=u-gt$ to $y'=u-y''t$. Then solve it to obtain a function $y(t)$. When $y'(t)=0$ we have the time for maximum vertical distance. Then insert the value to horizontal equation.   Can anyone guide me through this problem because I am not confident with my working I'm currently developing a script for Blender to handle Mesh Frequency Decomposition.  The script is nearly complete, but i need one more thing: The SciPy library to compute eigenvalues and eigenvectors.  Following the installation instructions on , I'm able to install it as well as Numpy. Numpy works fine, but I can't even import SciPy:  Traceback (most recent call last): File "/CAF_FD.py", line 4, in &lt;module&gt; ImportError: No module named 'scipy' Error: Python script fail, look in the console for now...   By the way, I'm working on Linux 64 bit and I've installed SciPy and Numpy with my package manager.  Edit: When I try to use SciPy with a terminal prompt, it works. I recently installed Ubuntu 17.10, and when I tried to set my keyboard layout to change with alt+shift, I hit a . There is  which works, but then it creates an unwanted behaviour on Firefox (perhaps other programs as well).   After setting alt+shift through gnome-tweak-tool as the combination to change language, whenever this combination is pressed within Firefox, it triggers a toggle that Firefox uses to show/hide the Menu Bar (with File/Edit/View etc.), and 'focus' is taken away from wherever the cursor was.   It's very frustrating, because one has to go and click again at the cursor.  The only solution I found was to permanently enable Menu Bar in Firefox because then alt doesn't do anything and I can use it to change languages. But I don't want to have Menu Bar on top always.  I hope you can understand what I'm trying to explain.  Any thoughts?