I'm using system() to do various commands such as ls -a. Is there any way that I can get system to store the output in an variable inside my program,  instead of printing the result to console?
I've got a utility that outputs a list of files required by a game.  How can I run that utility within a C program and grab its output so I can act on it within the same program? UPDATE: Good call on the lack of information.  The utility spits out a series of strings, and this is supposed to be portable across Mac/Windows/Linux.  Please note, I'm looking for a programmatic way to execute the utility and retain its output (which goes to stdout).
Get Response header when 401 occurred What's the Best Way to Shuffle an NSMutableArray? If you have an NSMutableArray, how do you shuffle the elements randomly?  (I have my own answer for this, which is posted below, but I'm new to Cocoa and I'm interested to know if there is a better way.)    Update: As noted by @Mukesh, as of iOS 10+ and macOS 10.12+, there is an -[NSMutableArray shuffledArray] method that can be used to shuffle. See  for details. (But note that this creates a new array, rather than shuffling the elements in place.) In my , I provided the following, problematic,  wording (especially bold italic), and I need help to better understand this issue so I can fix my answer:1          The thing is the books. (Reduced form of Sentence 2.a)         Fundamentally, Sentence 2.a (the so-called "correct" answer), is grammatically defective. Recall there is another grammatical rule: the subject and subject's complement should match in number.    A clarification is needed here. I am not suggesting here, in this EL&amp;U question, that there is any such singular grammatical rule as indicated in the quote above.  The quote continues as follows:     The reduced sentence makes the disagreement between the subject's and complement's plurality obvious. What is one to do? Language is linear and we know "The thing is X" is better than "The thing are X", so we go with the former, which is the subject-verb agreement rule. But what is "the books" then? It must be thought of as a collective noun, even if it doesn't look or feel like one. Forcing something to be a collective noun is related to the idea of notional agreement.   Others noted that grammatically defective is too strongly worded.  There is no such "grammatical rule" for subject/complement agreement.  Please help me understand/improve upon my line of thought here.  I'm stating that Sentence 2.1 presents a fundamental "conflict" or "error" (however one might define error) at some level (morphological, syntax, grammatical, semantic):     The thing is the books.  (Or, "The thing is the objects.")   Based on the "obvious" morphosyntactic plurality conflict, the above sentence feels so wrong that I think many native speakers would think it "simply" grammatically incorrect. However, @F.E. gives counter examples:     And here are some more grammatical examples, where the number of subject and predicative complement don't agree: "They were a problem to us all", "That so-called work of art is simply four pieces of driftwood glued together" (CGEL, page 254-5). As CGEL says: "What is required is semantic compatibility, not syntactic agreement . . .". There are more examples on page 512: "The only thing we need now is some new curtains", "The major asset of the team is its world-class opening bowlers", "Our neighbors are a nuisance", "This gadget is five different tools in one".   I think all the examples given above can be explained as notional agreement.    Question 1: If we explain this phenomena in terms of notional vs syntactic agreement, where does "grammatically correct/incorrect" fit in?  Question 2: Can a simple sentence such as "The thing is the objects." be grammatically incorrect while more complex sentences such as "The thing is four pieces of driftwood glued together." be grammatically correct?  (The answer, in my mind, must be no; this is my conundrum.)  Question 3: Would it be better to say that Sentence 2.a has a low level of (linguistic) ?   Question 4: How about a low level of  and that it's semantically difficult to be (linguistically) ?    Question 5: Do we simply draw a hard line and say "The thing is the objects." is 100% grammatically correct?  I didn't particularly like this option based on intuitive notions of "grammatically correct".    1. Please help me and be kind; I'm trying to improve my understanding. I'm looking for cool, objective advice on how to look at this.  I numbered my questions so they can be easily referenced, if desired.  My preference is the final answer would sufficiently answer all the questions, but of course that can be done explicitly or implicitly. Moderncv package - cventry date width TexShop will not compile without trashing aux files after every error I have a couple of LaTeX files with the same problem. If I produce an error, fix it, and then try to compile a pdf, I get the following error.  )Runaway argument? {{ ! File ended while scanning use of \@newl@ablel. &lt;inserted text&gt;                 \par l.90 \begin{document}   If I then click on the console or trash my .aux file, it compiles fine. Any thoughts on what is going on and how to prevent this annoying extra step? I've just received my new SSD since the old one died. This Intel 320 SSD supports TRIM. For testing purposes, my dealer put Windows on it, but I want to get rid of this and install Kubuntu on it.  It does not have to be a "secure wipe", I just need the empty the disk in the most healthy way. I believe that dd if=/dev/zero of=/dev/sda just fills the blocks with zeroes and thereby taking another write (correct me if I'm wrong).  I've seen the answer , but it looks like it's suited for clearing empty blocks, not wiping the disk.  hdparm seems to be the program to do it, but I'm not sure if it clears the disk OR cleans empty blocks. From its manual page:     --trim-sector-ranges           For  Solid State Drives (SSDs).  EXCEPTIONALLY DANGEROUS. DO NOT           USE THIS OPTION!!  Tells the drive firmware to discard  unneeded           data  sectors,  destroying  any  data that may have been present           within them.  This makes those sectors available  for  immediate           use  by  the firmware's garbage collection mechanism, to improve           scheduling for wear-leveling of the flash  media.   This  option           expects  one  or  more  sector range pairs immediately after the           option: an LBA starting address, a colon, and  a  sector  count,           with no intervening spaces.  EXCEPTIONALLY DANGEROUS. DO NOT USE           THIS OPTION!!              E.g.  hdparm --trim-sector-ranges 1000:4 7894:16 /dev/sdz   How can I make all blocks appear as empty using TRIM? I'd prefer as little formal definition as possible and simple mathematics. Let $A$ be a $n \times n$  invertible  matrix.Define a function $F:\mathbb{R}^{n} \times \mathbb{R}^{n} \rightarrow \mathbb{R}$ by $F(x,y)=\langle Ax,y\rangle$. Let $DF(x,y)$ denotes the derivative of $F$ at $(x,y)$ which is a linear transformation from $\mathbb{R}^{n} \times \mathbb{R}^{n} \rightarrow \mathbb{R} $. Then      1) if $x\neq 0$,then  $DF(x,0)\neq 0$      2) if $y\neq 0$,then  $DF(0,y)\neq 0$      3)  if $(x,y)\neq (0,0)$,then $DF(x,y)\neq 0$      4) if $x=0 \; or \;y=0$,then $DF(x,y)= 0$   I don't even know how to start the solution and also how to take derivative in higher dimensions.  Please help!  Thank you. full-screen browser window on load document Marriage Tax Benefits Where is it preferred to place the answer to duplicate questions? Windows 7 shows red "X" on network icon, but I'm connected How do I bypass restrictions on the length of the PATH variable System Properties      This environment variable is too large. This dialog allows setting values up to 2047 characters long.   I use/have used a lot of software, and my PATH has grown as a result. When I try to add new paths, I get the above message. As a workaround, I'm editing my user path, but prefer not to. I’m able to copy-paste from any application to any application. I’m able to copy from a comment or from a question or from an answer. I’m able to paste to a question or answer. However, if I attempt to paste into a comment, nothing happens. I am able to subsequently paste into another application, confirming that the text is actually on the clipboard.   However, copying SE links will paste them successfully, but all other text - including other links - still fails. This leads me to believe that it’s a SE issue and not an Apple one.   This has been an issue since 11.0 beta and persists through iOS 13 release. I am getting the following error trying to read from a socket. I'm doing a readInt() on that InputStream, and I am getting this error. Perusing the documentation this suggests that the client part of the connection closed the connection. In this scenario, I am the server.  I have access to the client log files and it is not closing the connection, and in fact its log files suggest I am closing the connection. So does anybody have an idea why this is happening? What else to check for? Does this arise when there are local resources that are perhaps reaching thresholds?    I do note that I have the following line:  socket.setSoTimeout(10000);   just prior to the readInt(). There is a reason for this (long story), but just curious, are there circumstances under which this might lead to the indicated error? I have the server running in my IDE, and I happened to leave my IDE stuck on a breakpoint, and I then noticed the exact same errors begin appearing in my own logs in my IDE.  Anyway, just mentioning it, hopefully not a red herring. :-( In Markov inequality proof, why is $\int_a^\infty xp(x) \, dx \ge \int_a^\infty ap(x) \, dx$ Markov inequality,   $$\Pr(X \ge a) \le \frac{E[x]}{a}$$  Proof  $$\begin{aligned}      E(X) &amp;= \int_0^\infty xp(x)\,dx = \int_0^a xp(x)\,dx + \int_a^\infty xp(x)\,dx \\       &amp;\ge \int_a^\infty xp(x)\,dx \ge \int_a^\infty ap(x) \, dx  \end{aligned}$$  Why is the last inequality true? Why is it ok to change $x$ to $a$, and we know it is less than or equal to? How did they figure it out? Thanks! Can photons be detected without being absorbed? I am thinking about a detector that would beep if light passes through it. Is it possible? What are instructions on how to download videos from YouTube?    Notice: Terms of Service Violation  Please be aware that by following any of the answers below, you will be violating YouTube's . In particular, from Section 5.B.:     Content is provided to you AS IS. You may access Content for your information and personal use solely as intended through the provided functionality of the Service and as permitted under these Terms of Service. You shall not download any Content unless you see a “download” or similar link displayed by YouTube on the Service for that Content. You shall not copy, reproduce, distribute, transmit, broadcast, display, sell, license, or otherwise exploit any Content for any other purposes without the prior written consent of YouTube or the respective licensors of the Content. YouTube and its licensors reserve all rights not expressly granted in and to the Service and the Content. QGIS area calculation differs when on the fly CRS transformation enabled When I open QGIS, add the layer, and calculate the areas of the shapefile via field calculator I get a different area than when I open QGIS and check "Enable on the fly CRS transformation" and calculate the area. This is despite making sure that the project and the layer have the same Coordinate system (same EPSG number). What am I doing wrong?   I have a shapefile with area calculations made with ArcGIS (not be me, the data was handed to me and I have no clue for which CRS the area was calculated with ArcGIS). The shapefile layer CRS is EPSG: 21781 (Switzerland). In QGIS, if I do not change the OTF settings and leave the project CRS as EPSG:4326 (WGS84) I get the same value as the ArcGIS area value. However, if I change the OTF before adding the layer to EPSG: 21781 I get different area values. As I understand this suggests that ArcGIS Area was calculated with the CRS EPSG: 4326.  First workflow:   open QGIS  project CRS: EPSG 4326  add layer  project CRS adapts automatically and is EPSG 21781 now  calculate $area with field calculator    Second workflow:   open QGIS  project CRS: EPSG 4326  Turn on OTF, set project CRS to EPSG 21781  add layer  calculate $area with field calculator    Step 5 of the first and second workflow DO NOT produce the same area. What is the relationship between lands and mana in Magic and what do each of them do?  A good answer should especially include how a new player should think about them.    Note:  This is an attempt to create a canonical question about the relationship between lands and mana in Magic.  Beginners are often confused about this given the same symbols are used to mean different things across basic lands, non-basic lands, and mana costs.  This can lead to confusion about , about , or even about .