For one of my homework, I have to read a file (~100 lines). To manipulate the content of the file and extract all the lines, I allocate a buffer with the size of the file with the function stat. And I read the file with the function read with this buffer. I was told that this method was dirty.  Why is it considered to be dirty? I think that if the file is short, it means the size of the char array is acceptable and it means only a few syscall??
How can I figure out the size of a file, in bytes?  #include &lt;stdio.h&gt;  unsigned int fsize(char* file){   //what goes here? }
Is the money you get from shorting a stock free to use for going long on other stocks? Unable to lock the administration directory (/var/lib/dpkg/), are you root? I get this error in Lubuntu 12.04 when I try to update in terminal:  $ apt-get update E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied) E: Unable to lock directory /var/lib/apt/lists/ E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? How do I find out which folder an app is in in iOS 11? In older versions of iOS, if I searched for an app with Spotlight, it would tell me which folder the app was in. (E.g., this feature still works on my iPad, which is running iOS 9, but not on my iPod Touch, which is running iOS 11.)  This feature seems to have been removed at some point. When I search for an app under iOS 11 using Spotlight, it will find the app and let me run it, but it doesn't tell me which folder it is in.  How can I find out which folder an app is in now? Combine the first two commits of a Git repository? Suppose you have a history containing the three commits A, B and C:  A-B-C   I would like to combine the two commits A and B to one commit AB:  AB-C   I tried  git rebase -i A   which opens up my editor with the following contents:  pick e97a17b B pick asd314f C   I change this to  squash e97a17b B pick asd314f C   Then Git 1.6.0.4 says:  Cannot 'squash' without a previous commit   Is there a way or is this just impossible? What is the best way to solve equations like the following:  $9x \equiv 33 \pmod{43}$  The only way I know would be to try all multiples of $43$ and $9$ and compare until I get $33$ for the remainder.  Is there a more efficient way ?   Help would be greatly appreciated! I have an array of Foo objects. How do I remove the second element of the array?  I need something similar to RemoveAt() but for a regular array. How to close/open a view panel I can't find a way to close a view panel, in particular the horizontal at the bottom, is pretty useless to me at this moment. Does SQLDeveloper support executing scripts? Draft mode for pgfplots I'm working on a fairly big document that has a lot of graphs of functions- so far it has around 200, by the end it will have around 1500. I use pgfplots for each graphic, and the functions are pretty basic: exponential, rational, polynomial, and trigonometric.  Once I am happy with each graph, I don't necessarily need to see it every time I compile, and would like to minimize compilation time for future drafts. Naturally, the document is already chopped up into chapter files, but each chapter contains around 100 figures.  Having studied the pgfplots documentation, I haven't found a draft mode, but I'm interested in knowing if one could be created.    I'm envisaging something similar to the draft mode of the graphicx package, in which graphics are not included, and blank boxes are put in their place.  Some things I've considered:   the  documentclass; but with about 1500 figures, wouldn't this mean over-modulization?  tikzexternalize, but this still requires an initial 'monster' compilation to get the images externalized before the draft option could be invoked   Here's a MWE to play with  \documentclass{article} \usepackage{pgfplots}  \begin{document}  \begin{tikzpicture}     \begin{axis}         \addplot {x^2};     \end{axis} \end{tikzpicture}  \end{document} Quotient rings of Gaussian integers I used this isomorphism today but now I'm having trouble justifying it. The norm function isn't additive so I can't come up with a ring isomorphism to prove the following:     For any $\,a+bi\in\Bbb Z[i],\,\gcd(a,b)=1$, we have a ring isomorphism   $$\Bbb Z[i]/\langle a+bi\rangle\,\cong\Bbb Z/(a^2+b^2)\Bbb Z=:\Bbb Z_{a^2+b^2}.$$   Could someone show me an isomorphism between these rings to prove this? Why do some tests have a (nonzero) minimum score? What is the difference between    a parameter passed by reference a parameter passed by value?   Could you give me some examples, please? Why there is a delay between when a key is pressed and when it is accepted? This is one of the wackiest and weirdest problems I have ever encountered. My keyboard was working absolutely fine untill yesterday on Ubuntu 13.04. However, when I boot to Ubuntu today, I suddenly find that all the keys work, but I have to press and keep on holding them for about a second for them to work.   This behavior is true for all the keys except for Num Lock, Caps Lock and Scroll Lock keys, the indicator for them on my keyboard lights up as soon as I press those keys. The keyboard works fine at the login screen where I put my password.  The keyboard also works normally if I use the Guest session instead of my normal user account. I have not done any key-remappings and using the standard English (US) keyboard layout.  I have fiddled around with the settings for Keyboard in System Settings, but to no avail. I have Windows 7 as dual-boot and the keyboard works perfectly well on it.   Why am I facing such a behavior and how to normalize this?  PS: Using Logitech Classic Keyboard K100 (USB Model). How can I prove this sequence is decreasing? My problem is how to prove  $$\frac{1+2}{1}  &gt; \frac{1+3+\frac{3^2}{2!}}{1+2} &gt; \frac{1+4+\frac{4^2}{2!}+\frac{4^3}{3!}}{1+3+\frac{3^2}{2!}}&gt;\cdots $$  i am sure that the sequence is decreasing as limit exp(1).  However, the reason why the sequence is decreasing is not evident.  Thanks if you consider this issue and make me relief. Sum of reciprocals of numbers with certain terms omitted Stack Overflow interesting questions implementation According to the tooltip of the 'interesting' tab, interesting questions are     "questions that may be of interest to you based on your history and tag preferences"   Does Stack Overflow use a recommendation engine or just some sql sort/filter? Simulation of interacting particles The Python docs say:     re.MULTILINE: When specified, the pattern character '^' matches at the beginning of the string and at the beginning of each line (immediately following each newline)... By default, '^' matches only at the beginning of the string...   So what's going on when I get the following unexpected result?  &gt;&gt;&gt; import re &gt;&gt;&gt; s = """// The quick brown fox. ... // Jumped over the lazy dog.""" &gt;&gt;&gt; re.sub('^//', '', s, re.MULTILINE) ' The quick brown fox.\n// Jumped over the lazy dog.' Automatically Locate Included Images rails - outputting user input with Paragraph Returns?