Wikipedia:Reference desk/Archives/Computing/2010 December 10

= December 10 =

Strings
Currently, I am taking lesson on "Strings". I couldn't run the following program. Got an alert signal on line 13:if (  strcmp  ( name, "Nahid" ) == 0 ) // Equal strings

How could I fix that? Thanks--NAHID 00:08, 10 December 2010 (UTC)


 * What alert did you get? Nimur (talk) 00:12, 10 December 2010 (UTC)


 * Could it be that you got "undefined identifier: strcmp"? Because you didn't , but iostream twice.  --Tardis (talk) 00:23, 10 December 2010 (UTC)
 * Visual C++ auto-included that header. I got an error on full name - which probably should be fullname.  Nimur (talk) 00:31, 10 December 2010 (UTC)


 * The alert shows a square shaped red box, but it did not explain anything to me. It only disappears if the sentence is fixed. I checked and wrote that line (13) again but it seems that problem did not go away. The box is still popping up.--NAHID 10:21, 10 December 2010 (UTC)


 * Put your mouse over the alert-box. A small arrow will appear to the right of the box; click on the arrow. A dialog box showing what the error is will be displayed. Or select View/Output (Ctrl+W, O), which will open a new window showing all the compilation errors and warnings. CS Miller (talk) 14:57, 10 December 2010 (UTC)


 * You may be getting a warning that strcmp is deprecated and that strncmp is recommended instead. APL (talk) 00:40, 11 December 2010 (UTC)


 * You do realise you have the same error ('full name' rather than 'fullname') in two consecutive lines? AndyTheGrump (talk) 01:05, 11 December 2010 (UTC)

Running WCII on a CF48
Whenever I try to run Warcraft II on my laptop (an old Panasonic Toughbook), I get the opening cinematic, but when the main menu comes up, it just shows as a blank screen. Alt-tabbing nets me a screen with blue lines running down it. I have no idea why it's acting like this (and yes, I do have the CD in the drive); any ideas?

For the sake of having the most complete info, this laptop is running Windows XP Pro (SP3), has a clock speed of 896 MHz, and has a total of 256 MB RAM. — Jeremy  ( v^_^v Hyper Combo K.O.! ) 05:08, 10 December 2010 (UTC)
 * Any ideas at all? — Jeremy  ( v^_^v Hyper Combo K.O.! ) 01:07, 11 December 2010 (UTC)


 * Run it under DOSBox? It is, after all, an old DOS game. 118.96.154.34 (talk) 17:20, 11 December 2010 (UTC)
 * The issue with that is that my desktop has no problem running the game, and it, too is an XP Pro SP3 rig. — Jeremy  ( v^_^v Hyper Combo K.O.! ) 21:00, 11 December 2010 (UTC)

torrent download
i recently downlaoded a torrent file and started the download, it went smoothly for about 2 hours, and i switched off the computer and when i switched it on again, the download doesn't continue. i mean, it shows downloading under the status tab, but there's no speed under the speed tab, remaining time is infinity. it's never happened with me before... is it a bad torrent??? can i do anything about it????

thanx —Preceding unsigned comment added by 117.197.240.5 (talk) 09:39, 10 December 2010 (UTC)


 * It could mean some of the people (or even just one person) you were downloading from also turned their computers off for a while. How many seeds and peers are showing for the download? Probably if you just leave the download going all the time it will catch when the other people reenter the swarm and start downloading again. There's nothing more you can do at your end but wait. 82.44.55.25 (talk) 10:34, 10 December 2010 (UTC)

usb ports
I plug an external hd (one partition, 250 GB): At first the pc (xp home, centrino) recognize it, after some minutes it behaves as I had unplugged it.. t.i.a. --217.194.34.103 (talk) 10:36, 10 December 2010 (UTC)
 * Could be a number of things. Failing drive, poor connector, ... After my own experience, the first I'd try is to leave the computer untouched with the drive plugged in. Does the drive stay online longer? If yes, that could indicate that small vibrations when you type etc are jiggling the connector, giving a poor electrical connection. Try to isolate the problem: if you have several USB ports, try another; if you have several cables, try another; if you have access to another computer, try the drive there. Does accessing the drive constantly make things better or worse (I'm thinking overheating vs. the drive going to sleep mode). Once upon a time I had an external drive that was failing by overheating; making a table fan blow on it helped me rescue the files. 88.112.59.31 (talk) 18:50, 10 December 2010 (UTC)


 * USB cable too long or USB cable wrapped around power or other cables causing interference. Does the HD have a separate power supply or does it get the power from the USB port; if the latter, then the port may not be providing enough power; use a powered hub, use a power supply with the HD if it has a connector or use a special USB Y cable to connect it to two USB ports for more power. ---— Gadget850 (Ed)  talk 18:58, 10 December 2010 (UTC)

Black screen
I have a Compaq Presario CQ60 that wont boot, when I turn it on the power light comes on and the HDD light at the front flickers but nothing happens. I connected it to another laptop using a VGA cable to see if it was the screen that was broken but get the same blank screen on the other laptop. Anyone any suggestions on what I could do to try to solve this thanks. Mo ainm ~Talk  14:08, 10 December 2010 (UTC)


 * It's no use connecting 2 laptops together and expecting one to display the other's output. You should try connecting it to a monitor. --86.133.83.252 (talk) 14:36, 10 December 2010 (UTC)


 * I tried that also and nothing but the black screen. Why would it make a difference between a monitor and another laptop? Mo ainm  ~Talk  14:47, 10 December 2010 (UTC)


 * The VGA connectors on laptops are for output only, if they receive an incoming signal (like you're trying to do) they wouldn't know what to do it, hence nothing appears.  ZX81    talk  15:17, 10 December 2010 (UTC)


 * Thanks for that explanation wsn't aware of that. But as I say I tried it on my PC monitor and nothing appeared. Mo ainm  ~Talk  15:19, 10 December 2010 (UTC)


 * You might need to enable the external monitor. The symbol is normally a hollow box with square brackets around it. Turn of the laptop and monitor. Connect the monitor, turn the monitor on, and finally turn the laptop on. Then press the button. You might need to hold down the Fn button as well. CS Miller (talk) 16:38, 10 December 2010 (UTC)


 * No, think I didn't get my question across properly the problem is that the laptop is not booting and all I get is a black screen I only connected it to another monitor to check if the screen was broke on the laptop it isn't so it is some other problem and this is what I am trying to discover.  Mo ainm  ~Talk  16:57, 10 December 2010 (UTC)


 * What does the machine sound like as it starts up? Do the fans start?  Do they stop again?  Does it do any beeping (beep codes are used to indicate problems that occur in early stages of booting)? It's probably not a screen problem, assuming that you mean that the HDD light flickers on briefly and then stops, because otherwise it be flickering constantly for a couple minutes.  Paul (Stansifer) 18:09, 10 December 2010 (UTC)


 * Yes the HDD is spinning and yes it is the HDD light at the front that flashes, it doesn't stay on or stay off. Mo ainm  ~Talk  18:21, 10 December 2010 (UTC)


 * Then maybe it is booting properly. Start it up, wait for a while, hook up the monitor.  The monitor may take a few seconds to recognize an input source.  Then hit Fn+F5 (or whatever controls the VGA out status) and see if that changes anything.  Paul (Stansifer) 22:42, 10 December 2010 (UTC)


 * I'm inclined to agree with the others, that this sounds more like a display problem than a failure to boot (which would normally result in some text-only error messages being displayed). However, it may not be the monitor, but the graphics card that's at fault.  Unfortunately, as most laptops aren't "user serviceable", this means a trip to the repair shop is needed.  One other possibility, going back to the monitor being the issue, is that the LCD back-light may not be functional.  Try shining a bright light at the monitor, at a shallow angle, in an otherwise dark room, to see if you can make out any text.  If so, then you know that's the problem.  I had this happen with one laptop, and I had to open it up to just the right angle to get the back-light to work. StuRat (talk) 07:59, 13 December 2010 (UTC)

Iterating through arrays
Instead of having to write "for n = 1 to x : j(n)=k(y): next n", which languages allow you to write something like: "iterate j=k(y)"? Thanks 92.15.0.115 (talk) 14:58, 10 December 2010 (UTC)


 * See foreach. —Bkell (talk) 15:24, 10 December 2010 (UTC)


 * See also map (higher-order function) and the even more powerful fold (higher-order function), which are features of functional languages. In most cases, those functions are even more direct than foreach-style loops.  ("foreach" is just a "map" that doesn't return anything, so you have to usher the information out of the loop by assignment statements.  The equivalent "map" can be much shorter.)  Paul (Stansifer) 15:53, 10 December 2010 (UTC)


 * See also also list comprehension and array programming. --Tardis (talk) 18:40, 10 December 2010 (UTC)


 * If you are using a language that lets you work with memory directly, such as memcpy in C++, you can do this. For example, mempcy takes a destination, source, and number of copies to make.  So, you could memcpy with j being the destination, k(y) being the source, and x being the number of copies to make. (and I think I should note that I do not believe this is an intended use for memcpy - it is more of a hack of how it works) --  k a i n a w &trade; 18:56, 10 December 2010 (UTC)
 *  memcpy memset(3) will only work if your element size is a byte. C++ has the more general fill and fill_n.  --Tardis (talk) 03:01, 11 December 2010 (UTC)
 * Are both of you are talking about memset, rather than memcpy? <tt>memcpy</tt> makes just one copy of the source; the third parameter is the size of the source. It works with any POD type, not just byte-sized types. <tt>memset</tt> can be used to zero out arrays of integers, but not to fill them with arbitrary values. -- BenRG (talk) 06:20, 11 December 2010 (UTC)
 * Yes, sorry: I deduced that Kainaw must have meant <tt>memset</tt> because it's filling the arbitrary-sized <tt>j(1:x)</tt> from the fixed size <tt>k(y)</tt>. Then I proceeded to repeat his apparent mistake in my discussion of it.  --Tardis (talk) 16:21, 11 December 2010 (UTC)


 * Another example of a high-level language with this functionality: in php you can do something like:
 * $my_array = array;
 * array_pad($my_array, $x, $k[$y]);
 * Then, my_array will be filled out to size x, all with value k[y]. -- k a i n a w &trade; 19:02, 10 December 2010 (UTC)
 * Assuming you want to replace all elements of the array, preserving the size, in Perl you can say <tt>@j = ($k[$y]) x @j;</tt>. In Python you can say <tt>j[:] = [k[y]] * len(j)</tt>. In C++ you can say <tt>fill(j.begin, j.end, k[y]);</tt> or <tt>j.assign(j.size, k[y]);</tt>. In Haskell you can say <tt>amap (const (k!y)) j</tt>. -- BenRG (talk) 06:20, 11 December 2010 (UTC)

Twitter
Someone has, for example, 20,000 "tweets". How do you view them in chronological order from oldest to newest? There's only a "more" link at the bottom of the page which loads 10 more messages each time you click it. 82.44.55.25 (talk) 17:11, 10 December 2010 (UTC)


 * Hi, when I'm using the most recent twitter interface in Firefox, there is no "more" button, just a continuous scroll down through a twitterers tweets. It does however go from most recent through to oldest, rather than the chronological flow that you asked about. Technically, I suppose that you could scroll the whole way down to the first tweet, and then start scrolling back up, reading chronologically from oldest to newest. I've run searches on a number of terms to try to find a tool that might list tweets as you requested, but wasn't successful, I also tried to run google searches on twitter accounts to see if google might be able to do it (a bit like a google news search where you can arrange the results by date) but this too was unsuccessful. My suggestion to go all the way to a users first tweet and then navigate through the timelie from there is the only option that I can see at this moment in time. Darigan (talk) 17:20, 16 December 2010 (UTC)

Can <tt>setjmp(3)</tt> evaluate its argument more than once?
The standard says that it's a macro, and in some implementations its argument is evaluated more than once. Is that a bug in that implementation (perhaps fixed since 2005), or is that allowed behavior? I don't see anything in the standard to forbid it, but it's obviously less useful if so (for the reasons mentioned in that mailing list post) and the standard doesn't specifically allow it either (like it does for <tt>putc</tt>). --Tardis (talk) 18:48, 10 December 2010 (UTC)
 * Here they say:
 * Each of the following statements shall apply unless explicitly stated otherwise in the detailed descriptions that follow: ... Any invocation of a function that is implemented as a macro shall expand to code that evaluates each of its arguments exactly once, fully protected by parentheses where necessary, so it is generally safe to use arbitrary expressions as arguments.
 * Since the only places they explicitly warn about multiple evaluations are in putc and friends, I think it's a bug for an implementation to do so with setjmp. That doesn't mean it doesn't happen, of course. --Sean 20:47, 10 December 2010 (UTC)
 * That's true; I knew that (if I thought about it), and it ought to be enough. Thanks.  (One could quibble that <tt>setjmp</tt> isn't a function at all, so it isn't a "function that is implemented as a macro".)  I wonder how frequent the implementations that do repeatedly evaluate are?  (The one I linked to was actually <tt>sigsetjmp</tt>/<tt>siglongjmp</tt>, but the same principle applies.)  --Tardis (talk) 21:57, 10 December 2010 (UTC)
 * I think this clause doesn't apply to this case for the reason you just stated. It's talking about the general provision that any standard library function may optionally (for speed reasons) be shadowed by a macro. Those macros are required to be as function-like as possible. I don't think that requirement extends to things that are explicitly stated to be macros. -- BenRG (talk) 04:37, 11 December 2010 (UTC)

How to allow firefox to access the web
How do I allow firefox to access the web? Albacore (talk) 21:19, 10 December 2010 (UTC)
 * One possible answer is to select File->Work Offline (remove the tick this option). A substantially different answer is that you need to pay an ISP for an internet connection. What's the nature of the problem? 213.122.23.184 (talk) 22:08, 10 December 2010 (UTC)
 * Aye, some more info would be nice, since Firefox is, after all, a Web browser. I have a question, though: Do you have a firewall? If so, is it either (a) blocking all access to Firefox or (b) on lockdown? — Jeremy  ( v^_^v Hyper Combo K.O.! ) 22:38, 10 December 2010 (UTC)
 * Firefox worked until it updated to a new version. Then, McAfee warned me that it was trying to connect to the internet, or something very similar. I chose "block" to block Firefox from connecting to the internet twice. Now, of course, Firefox won't load.
 * Based on that, I would imply that the firewall is blocking access to Firefox. Albacore (talk) 23:16, 10 December 2010 (UTC)
 * I'm not familiar with McAfee, but somewhere (perhaps an expert can tell you where), you will find a list of blocked software, and you just need to remove Firefox from that list.   D b f i r s   00:55, 12 December 2010 (UTC)

Quick to learn languages
The Short Introduction To ABC, linked from ABC (programming language) says that it can be learnt in "an hour or so or so for someone who has already programmed". Are there any other languages that could also be learnt in an hour or so? Thanks. 92.24.190.135 (talk) 22:47, 10 December 2010 (UTC)


 * Depends what you mean by learned. Brainfuck can be learned very rapidly - a few minutes to get the way it works. But whether you would be a competent programmer in that or any other language after an hour is a different matter. Usually the simpler the syntax and the fewer the languages options the quicker to learn and the longer to be competent at using it. -- SGBailey (talk) 23:27, 10 December 2010 (UTC)


 * Yeah, I don't consider learning something in an hour to be a very good sign generally. Chess can be learned in less than an hour, but that doesn't mean you'll be any good at it. --Mr.98 (talk) 00:05, 11 December 2010 (UTC)


 * I would think BASIC could be learned in an hour by somebody familiar with programming, and maybe Pascal (programming language) as well. Looie496 (talk) 02:58, 11 December 2010 (UTC)

Would not Logo (programming language) and others aimed at children in the List of educational programming languages be learnable by adults with some experience of programming, within an hour or so? Micro-SiMPLE with four commands could be learnt in a few minutes. 92.28.246.75 (talk) 13:21, 12 December 2010 (UTC)