What is the difference between:  int *array; array = (int*) calloc(5, sizeof(int));   and  int *array; array = calloc(5, sizeof(int));   I don't get it. Both samples work. At the university the professor explained why you need the (int*) before the calloc, but I didn't get it.  In the course was a code sample like this:  struct data{    int number;    char *name; }; typedef struct data student;  int main(){     student **list;     list = (student*) calloc(10, sizeof(student*));      //Create structures dynamic in list     ....      return 0; }   I hope someone can explain it to me. Thank you.
In , someone suggested in a  that I should not cast the result of malloc. i.e., I should do this: int *sieve = malloc(sizeof(int) * length);  rather than: int *sieve = (int *) malloc(sizeof(int) * length);  Why would this be the case?
How can standing waves be produced in an open organ pipe if the ends are open? How can standing waves be produced in an open organ pipe even though both of its ends are open? Can someone explain with more clarity? Is it possible to fail an ability check on purpose? Here are the general guidelines regarding ability checks:     The GM calls for an ability check when a character or monster attempts an action (other than an attack) that has a chance of failure. When the outcome is uncertain, the dice determine the results.   In some cases, you could want to fail an ability check. If you are climbing a wall an want to drop off, you fail simply because you stop attempting to climb, but in other cases, success and failure are both tied to the actual action and may both have desirable outcomes.  Example 1: Spell scrolls  An evil adversary wants you to cast a spell scroll for him, but you have him figured out and want to destroy his spell scroll instead, seemingly by accident. The rules on spell scrolls read:     If the spell is on your class’s spell list but of a higher level than you can normally cast, you must make an ability check using your spellcasting ability to determine whether you cast it successfully. The DC equals 10 + the spell’s level. On a failed check, the spell disappears from the scroll with no other effect.   A failure means that you successfully destroy the spell scroll.  Example 2: Amulet of the Planes  You are in possesion of the Amulet of the Planes. Your party is being overrun by terrible monsters, and the only way to save your party is to sacrifice yourself by sending yourself and the monsters to another plane of existence.     While wearing this Amulet, you can use an action to name a location that you are familiar with on another plane of existence. Then make a DC 15 Intelligence check. On a successful check, you cast the Plane Shift spell. On a failure, you and each creature and object within 15 feet of you travel to a random destination. Roll a d100. On a 1-60, you travel to a random location on the plane you named. On a 61-100, you travel to a randomly determined plane of existence.   By walking up to the monsters and failing the check, you and the monsters would be sent to another plane of existence.  The question  The rules seem to assume that you always want to succeed when you perform an ability check. Sometimes, however, you could want to fail on purpose. A sensible DM would rule that if you are skilled enough to succeed the check, then you would undoubtly be able to fail it on purpose as well. What does the rules as written say -- if anything -- about this circumstance?  According to RAW, is it possible to attempt an ability check and intentionally fail? Bravo for allowing comment editing, but what's the explanation for enforcing a five-minute window?  I think this might be over-engineering. If I have a spelling mistake or an inaccuracy I'd like to fix, I don't think the fact that five minutes has elapsed should prevent me from fixing it.  Further, if you are worried people will edit their comments in a way that makes the comment thread nonsensical, they can already do this by deleting their comment. So, limiting the ability to edit isn't really helping much in that regard.  Update  If people don't like this idea, I'm definitely open to hearing your reasons. For now, it seems like an unnecessary limitation of a quite awesome feature.  Update 2  Regarding John's scenario...     Me: Obama is cool!   You: You are right, man!      My edit: Obama is an idiot!   You: You are right, man!   ...this problem can still occur with deletions...     user1: Obama is cool!   user2: No, McCain is cool!   you: You are right, man!        user1: Obama is cool!   ---- deleted -----   you: You are right, man!     So, yes, editing could be abused as you suggest, but discontinuities can occur already because of deletions (and as someone else mentioned, because upvoted comments get prioritized upward).  As for Jeff's argument about rate limiting, I agree that is important, but I don't understand why you can't just use a CAPTCHA to prevent too many edits in a short period of time. chpasswd apply changes in the chroot directory This question is about an efficient way to compute principal components.   Many texts on linear PCA advocate using singular-value decomposition of the casewise data. That is, if we have data $\bf X$ and want to replace the variables (its columns) by principal components, we do SVD: $\bf X=USV'$, singular values (sq. roots of the eigenvalues) occupying the main diagonal of $\bf S$, right eigenvectors $\bf V$ are the orthogonal rotation matrix of axes-variables into axes-components, left eigenvectors $\bf U$ are like $\bf V$, only for cases. We can then compute component values as $ \bf C=XV=US$. Another way to do PCA of variables is via decomposition of $\bf R=X'X$ square matrix (i.e. $\bf R$  correlations or covariances etc., between the variables ). The decomposition may be eigen-decomposition or singular-value decomposition: with square symmetric positive semidefinite matrix, they will give the same result $\bf R=VLV'$ with eigenvalues as the diagonal of $\bf L$, and $\bf V$ as described earlier. Component values will be $\bf C=XV$.   Now, my question: if data $\bf X$ is a big matrix, and number of cases is (which is often a case) much greater than the number of variables, then way (1) is expected to be much slower than way (2), because way (1) applies a quite expensive algorithm (such as SVD) to a big matrix; it computes and stores huge matrix $\bf U$ which we really doesn't need in our case (the PCA of variables). If so, then why so many texbooks seem to advocate or just mention only way (1)? Maybe it is efficient and I'm missing something? Android/Java - Date Difference in days Is there a way to absolutely force a Log Out, Shut Down, or Restart with open tabs and unsaved documents? I could not find any relatively simple way to log out of a public use Mac quickly with many tabs open and unsaved document in the background without resorting to sudo shutdown -h now.  The reason I ask is that sometimes a user will have his/her account logged into the iMacs here at school and they would try to log off and then leave, thinking it has completed but the process is interrupted by Safari and Office apps, leaving their account, mounts, and websites still accessible to the next person who sits down.  Obviously a shortcut string would be nice instead of posting a note telling the person to type arcane things in a terminal. For example, just having them try to find Terminal.app is going to be a chore.  This doesn't seem to make sense because the user can just quit each app and click a few dialog boxes but unlike you and I to whom repeatedly pounding Command-Q while hitting the spacebar and D keys are probably second nature. Tool to create text files from a template I have to regularly create 100+ text files from templates. I currently use an overly complicated shell script. I think there is a smarter way to handle this, but I don't know how.  I have a "database" :  # outputfile      template            data1   data2    data3 first.txt         $template_main      $text1  abcd     1234 second.txt        $template_main      $text2  efgh     5678 third.txt         $template_other     $text1  ij       90   And a configuration file :  template_main=main.txt template_other=other.txt text1=whatever text2=blah   The templates are text files with placeholders like %%data2%% (the placeholder form can be changed).  Does someone know a tool to automate this better than with a complicated shell script ? How to create a bootable USB with multiple ISO images in it I want to remove the URL that gets printed on the bottom of the page.   like:  yomari.com/.../main.php?sen_n   How can it be omitted or prevent from getting printed?  To be more specific, is there any way I can prevent the page URL, date and the page title being printed along, while printing the web page? Agreeing on a single shortened nomenclature? I've noticed across various stack exchange sites that when they refer to their own stack exchange on their site, they'll shorten the name to something similar to either:  EE.SE (Electrical Engineering Stack Exchange) OR Tex.Sx (LaTeX Stack Exchange)  Essentially they'll do XX.SE or XX.SX which has the possibility to generate some confusion for new users.    Have I not visited enough sites and just noticed an outlier or would it be beneficial for Stack Exchange sites to agree on a shortened name nomenclature? How to gather full network usage statistics on a freebsd router? I have a freebsd box, which serves as a router from LAN to the outside world. It has several Internet providers, OpenVPN servers and clients, NAT and so on.  I would like to have complete statistics on when, who, to whom, via which provider, via which protocol, and how many bytes have been sent.   I agree that the minimal time scale will be an hour, i.e. no need for millisecond precision.  I tried vnstat2, ntopng and some other programs, but they don't seemed to have what I need or it is not obvious.   I don't understand, why this feature is not easily available. But I am not good in freebsd, so please, give me some clues. If $a^{n}-1$ is prime then $a=2$ and $n$ is prime? Proof that a sequence of continuous functions $(f_n)$ cannot converge pointwise to $1_\mathbb{Q}$ on $[0,1]$ Why is vote time missing in the SE data dump and SEDE? Ubuntu 18.04 No WiFi adapter found [Dell Inspiron 3542.] Just installed Ubuntu 18.04 but my WiFi adapter Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter doesn't work or even appear in the system settings.  output of lspci -knn | grep Net -A3:  &gt; rahul@rahul-Inspiron-3542:~$ lspci -knn | grep Net -A3 06:00.0 Network controller [0280]: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter [168c:0036] (rev 01)     Subsystem: Dell QCA9565 / AR9565 Wireless Network Adapter [1028:020c]     Kernel driver in use: ath9k     Kernel modules: ath9k 07:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller [10ec:8136] (rev 07)   output of lspci -knn | grep Net -A2  rahul@rahul-Inspiron-3542:~$ lspci -knn | grep Net -A2 06:00.0 Network controller [0280]: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter [168c:0036] (rev 01)     Subsystem: Dell QCA9565 / AR9565 Wireless Network Adapter [1028:020c]     Kernel driver in use: ath9k     Kernel modules: ath9k   output of sudo rfkill list  rahul@rahul-Inspiron-3542:~$ sudo rfkill list [sudo] password for rahul:  0: dell-rbtn: Wireless LAN     Soft blocked: yes     Hard blocked: yes 1: phy0: Wireless LAN     Soft blocked: no     Hard blocked: no 2: hci0: Bluetooth     Soft blocked: yes     Hard blocked: no   output of sudo lshw -C network  rahul@rahul-Inspiron-3542:~$ sudo lshw -C network   *-network DISABLED                description: Wireless interface        product: QCA9565 / AR9565 Wireless Network Adapter        vendor: Qualcomm Atheros        physical id: 0        bus info: pci@0000:06:00.0        logical name: wlp6s0        version: 01        serial: 4c:bb:58:30:aa:07        width: 64 bits        clock: 33MHz        capabilities: pm msi pciexpress bus_master cap_list rom ethernet physical wireless        configuration: broadcast=yes driver=ath9k driverversion=4.17.11-041711-generic firmware=N/A latency=0 link=no multicast=yes wireless=IEEE 802.11        resources: irq:18 memory:f7900000-f797ffff memory:f7980000-f798ffff   *-network        description: Ethernet interface        product: RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller        vendor: Realtek Semiconductor Co., Ltd.        physical id: 0        bus info: pci@0000:07:00.0        logical name: enp7s0        version: 07        serial: 74:e6:e2:14:2a:c8        size: 10Mbit/s        capacity: 100Mbit/s        width: 64 bits        clock: 33MHz        capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation        configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half firmware=rtl8106e-1_0.0.1 06/29/12 latency=0 link=no multicast=yes port=MII speed=10Mbit/s        resources: irq:19 ioport:e000(size=256) memory:f7800000-f7800fff memory:f2100000-f2103fff   *-network        description: Ethernet interface        physical id: 2        logical name: enp0s20u1        serial: 7a:14:5b:44:b4:96        capabilities: ethernet physical        configuration: broadcast=yes driver=rndis_host driverversion=22-Aug-2005 firmware=RNDIS device ip=192.168.42.109 link=yes multicast=yes   output of dmesg | grep ath9k  rahul@rahul-Inspiron-3542:~$ dmesg | grep ath9k [   23.712505] ath9k 0000:06:00.0 wlp6s0: renamed from wlan0   output of sudo iw dev  rahul@rahul-Inspiron-3542:~$ sudo iw dev [sudo] password for rahul:  phy#0     Interface wlp6s0         ifindex 3         wdev 0x1         addr 4c:bb:58:30:aa:07         type managed         txpower 0.00 dBm   output of dmesg   I already tried so many solutions but nothing works for me , I'm looking for answer from so many days. Please Someone solve my issue . If anyone want any other information please let me know.  Any help would be greatly appreciated. Algorithms for computing multiplicative order modulo $n$ If I take the $k \in \mathbb{N}$ power of 10 and mod it by a large prime, I notice that the remainders repeat at some point.  For instance $10^k mod~7$ seems to repeat every $8$th value of $k$.  Given $k$ (the power of ten), and a large prime number $p$, how can I compute the size of the cycle?  I tried writing a python script that computes the first instance of a repeat. However, I don't know if this works since a single instance of a repeat may not necessarily mean a full cycle. I have an HP ProBook 450 G2. Every time I shut down the computer and turn it back on after a day, the battery level decreases by about 5%. I'm sure that the computer is shut down, not in sleep or hibernate. I removed the battery from laptop and after inserting it, the battery percentage does not change. I tried updating the BIOS, disabling wake on LAN in BIOS options, and calibrating the battery several times.  Is this drain normal? If not, is it a hardware failure or can I fix it with software? Monotonicity in argmin function I have the following equation $$f(a)=\text{argmin}_{t\in\mathbb{R}} \sum_{i=1}^n\frac{1}{2}(1-a)(b_i-t)^2+a| b_i-t |, a\in[0,1]$$  How does one prove that the function is monotone in a? Show only hidden files (dot files) in ls alias