Jump to content

Wikipedia:Reference desk/Archives/Computing/2010 July 5

From Wikipedia, the free encyclopedia
Computing desk
< July 4 << Jun | July | Aug >> July 6 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


July 5

[edit]

Website addresses

[edit]

I have found that 99 times out of 100 (or so), I can type a website address with or without the initial "www" letters ... and I still am directed to the correct website. So, for example, www.burgerking.com would work just as well as burgerking.com (without the initial "www"). So, my question is: why do we have that "www" at all? What is the need or use for it? Why is it listed as part of one's website address if it is implied and essentially meaningless and irrelevant? Thanks. (64.252.65.146 (talk) 00:05, 5 July 2010 (UTC))[reply]

Someone will come with a better answer later, but in the interest of speed: The domain name system is read left to right (leaving out some parts) com - google - www (the server AT google named WWW that serves pages on the world wide web). As you said, most sites have it setup now where you can just type in the name without the WWW and there won't be a problem. --mboverload@ 00:10, 5 July 2010 (UTC)[reply]
Strictly burgerking.com is the domain name and www.burgerking.com is the name of a specific computer (or bunch of computers, sometimes) that burgerking operate. A decade or so ago, things were often organised to mail.burgerking.com was their mail server, www.burgerking.com was their world wide web server, irc.burgerking.com was their chat server, and so forth. Specifing the machine name helped burgerking figure out which service you were after. But it's possible to figure out which part of burgerking should get your traffic anyway, by distinguishing it using the internet port that's used (mail, web, chat, etc. use different internet ports). And these days burgerking.com gets so much web traffic that it can't be handled by a single computer any more (for a while you'd see www1.burgerking.com, www2.burgerking.com as they tried to spread the load). These days big sites will have an internet router that's smart (and load-balancing) and that figures out where all the traffic should go based on more complex rules. So burgerking's DNS server just sends all traffic to that router, which forwards it on to the correct internal machine. Others (such as Wikipedia) still use that machine name to mean something (even though, as at Wikipedia, it's no longer a single machine that services a single address). -- Finlay McWalterTalk 00:21, 5 July 2010 (UTC)[reply]
An excellent answer. --mboverload@ 03:12, 5 July 2010 (UTC)[reply]

Wow! Thanks for the answers. But, I did not understand a word that was said above. Can you please "dumb it down" for those like me who are computer / technology illiterate? Thanks. (64.252.65.146 (talk) 03:18, 5 July 2010 (UTC))[reply]

The website doesn't have their DNS records setup correctly so that just typing in burgerking.com would take you to their web server. DNS would be a good place to start. Perhaps someone will find a better way to put it. --mboverload@ 04:12, 5 July 2010 (UTC)[reply]
The simple answer is that it's a meaningless convention that persists only because people have come to expect it. There's no reason for it. -- BenRG (talk) 05:19, 5 July 2010 (UTC)[reply]
Well, I'll try anyway.
The string you type into a browser is used to determine the address of one or more computers; when you type it in a browser, you are (usually) sending a request out to the web for some computer to give you back a web page identified by that name. The string is translated to a computer address, the string is handed to a computer at that address, along with enough information to send the web page back to your computer.
"WWW" was a convention established in the very early days to mean "World Wide Web", and distinguished a web page from some other use of a 'domain'. As correctly identified above, "burgerking.com" is the domain; if you sent someone at that server an email, you would only use the "burgerking.com" part of the address, i.e., the domain. "burgerking.com" is unambiguous to the computers that translate string addresses into computer addresses; it translates to one such address, and that identifies a computer (or a group of computers that all respond to that address; google does not use one computer to respond to all of its hits).
"www" has become so common, and the first part of a web address is so seldom anything else, that it has become a default. I don't know where the default is applied; it could be in your browser or in one of the (many) machines involved in translating string addresses like that to computer addresses. But the "whole address" still has www, so it is accepted either way in your 99 out of 100 or so cases.
Occasionally you will find some large company that has addresses at something like "www2"; I'm not sure why this is, perhaps it helps the computers that do the translation to have a smaller group of addresses to look through (just all the www2 addresses, not all the www addresses). If the company had both a "www2.burgerking.com" and a "www.burgerking.com", you would need to type "www2" when you wanted that address. The only place I've seen this used is on a link, i.e., you use www.something to get to a page, and a link on that page goes to www2.
Strictly speaking, the whole address should be "http://www.burgerking.com", with "http:" designating the communication protocol ("HyperText Transfer Protocol") to be used. But that got assumed to be the default long ago, and so you don't have to type that, either.
Sometimes browsers will even add the ".com" for you -- try just "burgerking" in the address.
Is that any closer to what you were looking for?
rc (talk) 15:12, 5 July 2010 (UTC)[reply]
Yes, indeed ... very, very helpful. Thanks so much! (64.252.65.146 (talk) 16:23, 5 July 2010 (UTC))[reply]
As a minor correct/note I don't think it it's accurate to say the 'whole address' still has www. Well it may be for burgerking and it's perhaps true for a majority of websites, but it clearly doesn't have to be as I remarked in Wikipedia:Reference desk/Archives/Computing/2010 April 20#www.
If for example the A/AAAA record for the domain xyz.co.nz and subdomain www.xyz.co.nz point to the same IP address then clearly it's questionable if either one can be said to be the correct address from the DNS records alone, in other words there's no reason why the www has to be thought of as the whole address from that. If internal links in the server use www.xyz.co.nz (rather then relative links) or the server is advertised as www.xyz.co.nz then you could argue from the POV of the designers www.xyz.co.nz is the correct address (although in some cases you may see both and some may say your reading too much into something some random person who may not even understand the concepts involved and likely isn't really trying to make such a decision did). Of course if the server always redirects you to the www if you visit the subdomain that that's far better evidence the www is correct (even if has the same A/AAAA record). If there is no A/AAAA record for the main domain instead a CNAME pointing to the www subdomain, then in that case you could likely argue the www is the 'correct address' (although it could also be the opposite in some cases). If there are different records, with for example the A/AAAA record for the main domain pointing to a server that does say a 302 redirection to the www.xyz.co.nz (well probably other things for other traffic) then also you can say the www is the correct address. Of course there are whole lot of other possibilities that I haven't mentioned including many things that I'm not aware, my knowledge of DNS records and web server configurations isn't that great (although I do have a domain name for personal use).
But to summarise, there are many different possibilities and in some cases whether www.xyz.co.nz or xyz.co.nz is the correct URL for the companies website is a rather complex and perhaps even unanswerable question.
Note that www.xyz.co.nz (or www) is a subdomain of xyz.co.nz (or xyz) which is a subdomain of co.nz (or co) which is a subdomain of nz (ditto for www.burgerking.com, burgerking.com and com). Both xyz.co.nz and www.xyz.co.nz are domain names. A decent example is you can get a domain name as whatever.name.my but name.my actually has DNS records, these are used to forward e-mail for name.my so anyone with a whatever.name.my actually get to use a whatever@name.my e-mail address if they want to. my also supports 2LD so you can also get whatever.my.
Nil Einne (talk) 17:39, 5 July 2010 (UTC)[reply]
See World Wide Web#WWW prefix (permanent link here).—Wavelength (talk) 17:05, 5 July 2010 (UTC)[reply]

Thanks to all for the above input. It was very helpful and much appreciated. Thank you! (64.252.65.146 (talk) 19:13, 17 July 2010 (UTC))[reply]

PlaySound function in MSDN library

[edit]

When I use the PlaySound function on a .wav file, it only plays a part of the file. For example, it plays only the first 58 seconds of a 76-second file and only the first 78 seconds of a three-minute file. Is this a known problem? Why does this happen?

I'm using 32-bit Windows. The PlaySound function is used in a Win32 console application that I created using Microsoft Visual C++. --Bowlhover (talk) 03:16, 5 July 2010 (UTC)[reply]

Do you have a minimal example that illustrates the problem? For example, are you using SND_SYNC or SND_ASYNC? decltype (talk) 22:52, 6 July 2010 (UTC)[reply]

How do one toggle scrollbars in Firefox (for Windows)?

[edit]

Popup-windows often appear without scrollbars even when the content is too big to fit within the window. (Because I use large fonts).

Is it possible to toggle the scrollbar(s) manually (in Firefox 3.6.6)?
--Seren-dipper (talk) 04:24, 5 July 2010 (UTC)[reply]

See if this addon will help you. Popups use javascript to disable features. Use this addon to block that. --mboverload@ 04:41, 5 July 2010 (UTC)[reply]

Templates

[edit]

Hi there. On my wiki, there is a template I copied from here, but when I put it onto the page, it just shows the syntax of the template! HELP! Velociraptor888 12:08, 5 July 2010 (UTC)[reply]

Why isn't anyone replying? Velociraptor888 12:47, 5 July 2010 (UTC)[reply]

Have you read the bit at the top of the page under "When will I get an answer?" ? --Phil Holmes (talk) 13:04, 5 July 2010 (UTC)[reply]

Velociraptor888: Which template did you copy? --59.95.105.39 (talk) 13:28, 5 July 2010 (UTC)[reply]

Template:Round16. Velociraptor888 15:16, 5 July 2010 (UTC)[reply]

That template uses parser functions, which means that the parser functions extension needs to be installed and enabled. also, if has a dependency of template {{!}}, used for creating conditional table elements, so you'll need to copy over that template as well. --Ludwigs2 17:21, 5 July 2010 (UTC)[reply]
Thank you, Ludwigs2! But how do you isntall parser functions on a wiki? Velociraptor888 20:23, 5 July 2010 (UTC)[reply]

In addition to the parser functions most templates have a HUGE cascade of other templates they rely on to make them work. Like 50+ for info box I think. This will take an hour or more, especially if you're not familiar with Mediawiki.

  1. Find the template you want to have on your wiki
  2. Edit the template on Wikipedia. For example, for infobox
  3. At the bottom of the text box you will see "Pages transcluded onto the current version of this page:"
  4. Open ALL of those pages into tabs in your browser and edit them. Copy them all (named the same) into your wiki
  5. With those tabs open you then need to find "Pages transcluded onto the current version of this page:" on EVERY ONE of those templates and REPEAT the steps above.

It's a big job. I had to do it. --mboverload@ 21:41, 5 July 2010 (UTC)[reply]

OK. I see. But judt how do you isntall parser functions on a wiki? Velociraptor888 09:09, 6 July 2010 (UTC)[reply]

Could anyone tell me how to install parser functions on a wiki? Hello! Velociraptor888 18:50, 6 July 2010 (UTC)[reply]

COME ON, REPLY! And also, I've copied Template: Infobox international football competition, but it just saying "No title" and "No information". Velociraptor888 19:18, 6 July 2010 (UTC)[reply]

Yelling at us is rude and not likely to encourage responses. As the instructions at the top of this page indicate, it may take several days for an answer. -- Coneslayer (talk) 19:21, 6 July 2010 (UTC)[reply]

Sorry, but how can you fix my two problems? Velociraptor888 19:23, 6 July 2010 (UTC)[reply]

I can't, because I don't know anything about setting up MediaWiki. When somebody who can help comes along, they will probably respond, if you seem like the sort of person that they would like to interact with. -- Coneslayer (talk) 19:24, 6 July 2010 (UTC)[reply]
Velociraptor888: you might try reading the mediawiki docs. start with mw:Extension:ParserFunctions. I hope this solves your problem, because I am losing interest in giving you any further advice. If I wanted to deal with screaming brats I'd have had kids of my own. --Ludwigs2 20:11, 6 July 2010 (UTC)[reply]

JavaScript help

[edit]

What could cause the browser to have difficulty converting form elements into an object document.formname[x].value? —Preceding unsigned comment added by 59.189.217.216 (talk) 13:00, 5 July 2010 (UTC)[reply]

I'm afraid we're probably going to need a little more detail here. What kind of "difficulty"? What's the result? What's the browser? And, if you can, what's the code itself? Because otherwise the easiest answers, just given the above are "you're doing something wrong" and "javascript can be squirrelly sometimes," neither of which are very useful to you. --Mr.98 (talk) 15:51, 5 July 2010 (UTC)[reply]

DIgital Pictures

[edit]

Is there any program that I can use to see with what camera a jpeg has been taken ? The megpixel of the camera/pic ? The other hidden details in the picture ? For example I took this picture using a very cheap digital camera JXD. What is the megapixel capacity of the camera ? The pic is 1200 X 1600 but pictures of same (or even lesser) size taken by others is far, far better. Why ?  Jon Ascton  (talk) 17:38, 5 July 2010 (UTC)[reply]

See EXIF and feel free to come back with any other questions if that doesn't answer it. Zunaid 18:09, 5 July 2010 (UTC)[reply]
Not all files contain EXIF data, alas. --Mr.98 (talk) 18:30, 5 July 2010 (UTC)[reply]
A megapixel is just a count of the total pixels (see Pixel#Megapixel). So for 1200x1600 = 1.92 megapixels. Not so great, especially when a close examination of the image makes it look like it is not really able to do a true 1.92 MP, but is interpolating a lot of the detail (which is very clear at the edges of the flower, where you are getting really "chunky" pixels). --Mr.98 (talk) 18:30, 5 July 2010 (UTC)[reply]
Why are other pic of same (or even lesser) pixels so clear,then ? For example this 512 × 768 pixels (what a beauty, by the way !!) is far more clear than my miserable picture. Why ? Jon Ascton  (talk) 19:37, 5 July 2010 (UTC)[reply]
I'm not following you. But in camera sensors (and scanners) there is a hardware resolution and a software resolution. The hardware resolution is what the sensor can actually process without any help. The software resolution is when you take smaller amounts of data and try to extrapolate upwards. My suspicion is that the camera has a very low software resolution and then uses software to interpolate a larger image out of it. This method always produces blurry artifacts. High-end cameras have bigger and better sensors in the back of them, and can reproduce high amounts of detail that way without resorting to software resizing. --Mr.98 (talk) 19:41, 5 July 2010 (UTC)[reply]
Ok. Does that simply put mean more costly a camera more high quality the result. (The pic was actually taken by camera in-built in a MP4 player, not a proper digital camera)? Jon Ascton  (talk) 19:50, 5 July 2010 (UTC)[reply]
There is clear pixelation in the full-size image suggesting that it was scaled up from a much lower resolution. It looks like the sensor is actually around 576×432 pixels and the image is scaled up to 1600×1200 after the fact, allowing them to claim "two megapixels" instead of the actual 0.25. Additionally, the flower in the foreground is simply out of focus, and would look blurry at any resolution. If this is a fixed-focus camera, there's no remedy for that but moving farther away from the subject. -- BenRG (talk) 01:16, 6 July 2010 (UTC)[reply]
The image quality is largely dependent on the quality of the lens, then the quality of your focussing system, then the quality (and physical size) of the sensor, then lastly the number of megapixels. That is why a 6-megapixel digital SLR with a high quality lens and a large CMOS sensor will always take better photos than a 12 megapixel point-and-shoot with a tiny CCD sensor.
To go in depth: the quality of the lens determines the sharpness of the image coming into the sensor in the first place. A poor lens will not show the subject in that crisp "pin-sharp" focus that is the hallmark of a stunning photograph. Smaller lenses on point-and-shoots also offer much less depth of field so you don't have that effect where the subject is pin-sharp and stands out against a background that is blurred. Secondly the qualty of your focussing system determines how well and how accurately the camera determines the distance to the subject in order to set the the lens to the proper focal length. Higher quality cameras have better systems than can work well even in very low light when focussing is especially hard. Cheaper cameras will often "hunt" for the focus point in low light. Still cheaper cameras (e.g. phones and yes, MP4 players) will likely just have a fixed focal length set to something like 2-3m from the camera. Thirdly, the quality of your sensor determines the amount of thermal noise you'll get in an image, the larger sensors in SLRs means that each individual pixel is physically bigger therefore captures more light so your signal-to-noise ratio is much higher than for cheap, tiny CCD sensors. Note that cheap cameras often chase megapixels as a marketing ploy (most consumers think more=better) when in actual fact the more pixels you pack into a sensor of the same size, the smaller each individual pixel must be (which results in poorer SNR and "grainy" shots). Finally the number of megapixels only determines to what size you can print a photo. Since most people never print their digital images, even a 2-megapixel camera is more than sufficient for creating nice slideshows on a PC monitor. 3-megapixels is quite sufficient to print photos in the standard 5"x7". Therefore anything higher than these limits are only useful when printing LARGE posters or when cropping images and wanting to print what's left at decent quality. Otherwise it's just a waste of space and a marketing ploy to sell an inferior product. Hope this helps. Zunaid 20:20, 5 July 2010 (UTC)[reply]
Cropping or zooming (I think this is an important distinction because many people may zoom in interest details or whatever even if they never bother to crop the photo for display or are just viewing it on screen). Nil Einne (talk) 21:21, 5 July 2010 (UTC)[reply]
You get what you pay for. The $1000-$2000 Nikons/Canons take stunning pictures without much effort, although I must say my $400 Sony H20 with 10x optical zoom and Carl Zeiss lens takes excellent pics, not to mention the HD video recording bonus which is so good, I don't need to lug my digital camcorder around anymore. Proper cameras are a million times better than cellphone cameras. Sandman30s (talk) 22:37, 5 July 2010 (UTC)[reply]
It depends what you mean by a 'proper camera' and a cell phone camera I guess. There are plenty of cheap P&S digital cameras nowadays. These aren't likely to be that much better (perhaps still better but not even close to a million times) then a high end camera phone (I'm thinking something like a Pixon or one of the good Sony Ericsson's or whatever where the camera is a core feature of the phone). One thing many lack I guess because of the thickness, size, weight and logistics issue and consumer demands is optical zoom, most cheap digital cameras will have 3x but even many of the better camera phones don't.
K-touch (Tianyu) of China [1] are one which do IMHO produce okay cameras with optical zoom attached to a phone (I say that because in some ways that's how they are designed, the earlier designs even used seperate memory cards for the phone and camera part), the phone part isn't that great (but does the basics which may be enough for some). Some e.g. photos and reviews [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]. As I said IMHO their output is okay considering these are cheap phones and the size (an Ixus would be a better camera, as shown in one of the reviews but also potentially more expensive and in any case doesn't have a phone), there are quite a few different ones, all launched not that far apart and it was over a year ago (haven't see anything new) but the price now seems to be about 800 Yuan or US$120 (perhaps about double or so at launch time I think). Altek a Taiwanese digital camera maker (who may have helped design the K-touch camera phones) appear to be getting into the act too.
A decent digital camera will do loads better (as a case in point one of the reviews bizzarely compared a 2005 SLR to one of the 2008 K-touches, unsurprisingly the SLR was clearly far better) but of course most people don't carry cameras with them all the time and I personally do find the idea of having such a camera phone interesting. Of course a $400 camera with 10x optical zoom will be even better still but many people don't have something even close to that. (Video is also another shortcoming of many even high end camera phones.)
This isn't to say many/most mobiles do have totally shit camera, cheap Chinese brand phones (probably the same for cheap Indian brand phones) are notable for completely bullshit specs on the cameras (and completely shit cameras).
Nil Einne (talk) 05:04, 7 July 2010 (UTC)[reply]

Quick request to loop an animated GIF

[edit]
Resolved

Hi. I created and uploaded the following file today but didn't realise it lacks impact without the animation looping. It's a GIF of Thomas Müller's opening goal for Germany against Argentina. Could someone with a GIF editor please edit it and set it to loop? Also feel free to adjust the frame rate if it's too fast. I would do it but I'm bandwidth constrained (using my 3G card because our ADSL is acting up this evening). The file is at Commons: http://commons.wikimedia.org/wiki/File:FIFA_World_Cup_2010_Argentina_vs_Germany_-_Thomas_Müller_opening_goal.gif

Please download the full-res version, make the adjustments and upload it again. Thanks! (p.s. I know the Graphics Lab is probably the "correct" place to ask but I'm sure RD/C will do just fine.) Zunaid 18:08, 5 July 2010 (UTC)[reply]

Never mind. ADSL is back up so I've done it myself. Reduced the frame-rate to 1 per second and added the loop as required. Zunaid 20:42, 5 July 2010 (UTC)[reply]
I dare suggest that the movie makes almost no sense to me. It's too hard to see where the ball is and the cuts really don't give any indication of its trajectory (it seems to be all over the place). As a useful encyclopedic graphic, either a static image, or a true movie, would probably be better than a large and herky-jerky animated GIF. --Mr.98 (talk) 21:35, 5 July 2010 (UTC)[reply]
Or at least reduce the dimensions of the gif to say 300px and add more frames so it plays smoother. 82.43.90.93 (talk) 22:51, 5 July 2010 (UTC)[reply]
Agree with Mr.98, I cannot immediately recognise this as 'useful'. Why cannot it be cropped? --Ouro (blah blah) 05:17, 6 July 2010 (UTC)[reply]
I have to agree with the above; it doesn't impart any useful information to me. It's also presumably a copyvio. Comet Tuttle (talk) 05:35, 6 July 2010 (UTC)[reply]
Was I really the only one who realised this was almost definitely a bunch of burst photos Zunaid (who does after all come from South Africa) was lucky enough to take of the goal? I admit I did initally wonder why the heck animated GIF instead of a Theora but upon looking at it I realised this was probably a bunch of photos not a video so it wasn't surprising it was an animated GIF and there likely wasn't anything better available. Most of the above comments appearing to be presuming something else Nil Einne (talk) 02:52, 7 July 2010 (UTC)[reply]

That's as fast as my camera's burst mode would take. I spent an hour aligning, cropping and resizing the original JPEGs to make the GIF so it's just a "quick and dirty" image to get into the article whilst the interest in the World Cup is still high. I'm busy working on a better version where I will crop and zoom each image differently in order to track the trajectory of the ball, however the time gap between shots is fixed as I mentioned before. This is as best as I can do; I can almost guarantee no-one else who has similar footage knows how to contribute it to Wikipedia. Take it or leave it. Zunaid 05:43, 6 July 2010 (UTC)[reply]

It needs additional alignment and image registration. This should be done algorithmically. I will attempt to perform such processing and if my result is any better, I'll post it as a second version. (Manual image-registration can only go so far - I'm impressed you got this much alignment by hand!) If you have unprocessed, higher-quality / higher-resolution source images, let me know - those will work even better as inputs to an algorithm than the current (compressed) GIF frames. I have both commercial and home-brew/open-source options, I can try both techniques. Nimur (talk) 20:49, 6 July 2010 (UTC)[reply]
Nothing impressive, all I did was crop it so that the top left corner of the goal post was at the same (x,y) co-ordinate in each frame. I should have straightened the images first but was using Paint.net which doesn't have that feature. I'll answer you on my talk page. Zunaid 22:13, 6 July 2010 (UTC)[reply]
I just want to point out there can be more than "take it or leave it". For example, sometimes sequential data is not best when animated. I personally find this series much more useful in understanding cloud formation than this animation of it. The juxtaposition of images lets you see—backwards and forwards—how they change from one to the other, and see the overall evolution without losing track of what it looked like at the beginning. The animation loses all of that detail and you just get a choppy version of something we've seen a thousand times before. I think in your case that a good sequence of the goal shot might be more useful to the viewer than a choppy animation, which as you point out has many limitations. Instead of being a bad animation, make it into a good sequence. (Would involve some cropping.) Just my two cents. It's not a question of "the camera didn't burst well enough" or "take it or leave it"—it's, "how can we best make this into something useful, informative, encyclopedic, and something that you and I would both take great pride in being used on Wikipedia." It's about making the best image out of what we have—which might mean trying out some different things, and not just assuming that "video is best" because that's how TV does it. --Mr.98 (talk) 00:48, 7 July 2010 (UTC)[reply]

Quick C question

[edit]
Resolved

Hello everyone, I was curious; why does the following run correctly:

#include <stdio.h>
#include <string.h>

int main() {
   char message[10];                //note the length of 10
   int count, i;

   strcpy(message, "Hello, world!");

   printf("Repeat how many times? ");
   scanf("%d", &count);

   for(i=0; i<count ; i++)
      printf("%3d - %s\n", i, message);
}

"Hello world!" should not fit in a char array of size 10. I tried a char array of size 1 and the program ran fine (I did get a segmentation fault message at the end with message set to size 1). Thanks! 76.14.36.82 (talk) 23:11, 5 July 2010 (UTC)[reply]

In normal operation, C does not perform bounds-checking on arrays. So it's a very common error to reference memory off the end (or sometimes off the beginning) of an array. This is bad, you should never do it, horribly things will happen, but you very often will not get an (immediate) error. A segmentation fault does not mean "bad array reference error" - it means you've run so far off the end of memory (or off into some random space) that you've hit a chunk of your process' address space which hasn't been allocated at all, and only then does the OS notice and kill your process with a segmentation fault. This is why C programming is hard, or rather why C debugging is hard; problems lie dormant in code for years. In this case, depending on how the stack is organised, you'll be stomping over other automatic variables or over the return frame. What's happening when you set the length down to 1 is that you are indeed trashing the return frame of main, and when main finishes it tries to return to an address stored in that frame - but you've trashed that, so it returns to a nonsense address, and that's a segfault. Running your program in an environment which does enforce bounds checking can find some of these problems (try valgrind or purify) but really the responsibility is chiefly the programmer's. It's common practice in some companies to ban use of strcpy and make people use strncpy and the like, not because it's really that much safer, but because it forces you to think about how much memory you have to write into. -- Finlay McWalterTalk 00:08, 6 July 2010 (UTC)[reply]
Thank you!! 76.14.36.82 (talk) 01:41, 6 July 2010 (UTC)[reply]