Wikipedia:Reference desk/Archives/Computing/2012 September 23
Computing desk | ||
---|---|---|
< September 22 | << Aug | September | Oct >> | September 24 > |
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. |
September 23
[edit]about files in c
[edit]i am not able to below lines "data is stored as lines of characters with each line terminated by \n which may be translated into carriage return +line feed" my doubts: 1)what is the meaning of carriage return what is the meaning of line feed? — Preceding unsigned comment added by Phanihup (talk • contribs) 01:09, 23 September 2012 (UTC)
- See carriage return and line feed. So, together they mean you go to the beginning of the next line in the file. StuRat (talk) 01:10, 23 September 2012 (UTC)
- Note that the line ending conventions vary based on operating system. The carriage return+line feed convention is used in Windows, but Unix-based systems (including Linux and Mac OS X) just use line feed (with an implicit "return to the first part of the line when you advance a line"), and Mac OSs prior to OS X used just a carriage return (with an implicit "advance a line with the return"). Other systems may have their own conventions for ending a line of text, which may not involve a carriage return or line feed at all. (Though as I understand the C standard, they would still be represented by '\n' in C strings on those systems.) -- 71.35.101.136 (talk) 19:05, 23 September 2012 (UTC)
- "\n" is translated to and from whatever the end-of-line convention on any given system is by the standard C library stream functions only (those working on FILE* streams. This translation does not happen in strings, and does not, e.g., affect low-level read() and write() calls. The strlen of "a\n" is always two, even if printf("a\n") sends 3 characters to the terminal. --Stephan Schulz (talk) 20:38, 23 September 2012 (UTC)
- Note that the line ending conventions vary based on operating system. The carriage return+line feed convention is used in Windows, but Unix-based systems (including Linux and Mac OS X) just use line feed (with an implicit "return to the first part of the line when you advance a line"), and Mac OSs prior to OS X used just a carriage return (with an implicit "advance a line with the return"). Other systems may have their own conventions for ending a line of text, which may not involve a carriage return or line feed at all. (Though as I understand the C standard, they would still be represented by '\n' in C strings on those systems.) -- 71.35.101.136 (talk) 19:05, 23 September 2012 (UTC)
- That's not entirely correct. It depends on how the file is opened. If a file is opened in text mode, fopen("foo.txt", "wt"), \n will be translated to \r\n when writing. If it is opened in binary mode, fopen("foo.txt", "wb"), translation does not take place. The same holds true for reading files, \r\n is translated to \n when reading files opened in text mode, fopen("foo.txt", "rt"). Each character is returned if the file is opened in binary mode, fopen("foo.txt", "rb"). See [1]. --NorwegianBlue talk 21:19, 23 September 2012 (UTC)
- Well, on UNIX and Linux there is no distinction between a binary and a text file. All files are opened as binary files (i.e fopen("foo", "wb") is equivalent to fopen("foo", "w")) [POSIX fopen()] Ebaychatter0 (talk) 00:54, 24 September 2012 (UTC)
- Actually it does affect the "low-level" read() and write() calls. On Unix those are operating system calls that just deal with bytes, but on Unix there's no difference between the text and binary modes anyway. On Windows, some Unix system calls including open() and read() and write() are provided to make it easier to port programs that use them, even though they aren't part of the C standard. They're implemented in the C library and they do perform newline conversion if you pass the O_TEXT flag to open(). -- BenRG (talk) 04:01, 25 September 2012 (UTC)
Polymorphism
[edit]hi ! polymorphism means one message peforms different operations on the object which it receives. then " what is the benefit of polymorphism in c++?"?why polymorphism? suppose you consider function overloading. what is the benefit of using same function for different purposes? can you explain clearly? — Preceding unsigned comment added by Phanihup (talk • contribs) 01:19, 23 September 2012 (UTC)
- Well, often that just means the same function on different data types. For example, you could have a square root function for short integers, one for long integers, one for real numbers, one for double length real numbers, etc. StuRat (talk) 01:31, 23 September 2012 (UTC)
- It's even more common for a ToString() function. Converting a number to a string could be a completely different operation to converting a colour to a string, but ToString(int) and ToString(colour) could both work with polymorphism.--Phil Holmes (talk) 09:37, 23 September 2012 (UTC)
- See: Polymorphism (computer science) and Polymorphism in object-oriented programming. Mitch Ames (talk) 14:15, 24 September 2012 (UTC)
Guest account on private wiki
[edit]I have recently created a private wiki to be used in a collaborative project, and need to add a guest account, i.e. an account with read-only access to the wiki. I am using mediawiki-1.16.1 on a hosted Linux server. The installer created the following lines in LocalSettings.php:
# The following permissions were set based on your choice in the installer $wgGroupPermissions['*']['createaccount'] = false; $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['read'] = false;
I tried adding, below that,
$wgGroupPermissions['Gjest']['read'] = 'true';
and created a user 'Gjest', but the 'Gjest' user received normal editing privileges. I'd be grateful if someone could advise me about how to add a guest account to the wiki. --NorwegianBlue talk 08:57, 23 September 2012 (UTC)
- Solved it, sort of, by adding the following at the end of LocalSettings.php:
$wgGroupPermissions['user']['createaccount'] = false; $wgGroupPermissions['user']['edit'] = false; $wgGroupPermissions['sysop']['createaccount'] = true; $wgGroupPermissions['sysop']['edit'] = true;
- i.e. normal user accounts lose editing rights, and serve as guest accounts. To edit the wiki, you need to be an administrator. I'm sure there's a better way, but for this small project, this solves the problem. --NorwegianBlue talk 14:18, 23 September 2012 (UTC)
- You might have better luck with this question at mw:Project:Support desk. 69.228.171.70 (talk) 18:57, 24 September 2012 (UTC)
How to enable turn-by-turn navigation with voice on iOS 6 running on iPad 3?
[edit]I can't figure it out. Write English in Cyrillic (talk) 10:13, 23 September 2012 (UTC)
- Is Siri enabled? Moondyne (talk) 14:23, 23 September 2012 (UTC)
Game name wanted
[edit]Hi all, maybe you can help... i'm searching for a mini-game in which one has to operate a rotary telephone in order to correctly set a series of strowger switches. Anyone has an idea how the game is called? thanks,85.181.73.55 (talk) 19:17, 23 September 2012 (UTC)
- You might have more luck at the Entertainment desk, which lists video games among the topics covered.—Odysseus1479 (talk) 03:49, 24 September 2012 (UTC)
Why are Android smartphones are so popular in Spain (and iPhones so unpopular)?
[edit]August sales charts showed that 90% of newly sold smartphones in Spain are using Android OS and only 2.9% (compared to 35.2% in US) are made on iOS. What are the social reasons for it? Do Spanish people, eh, think different? (pun intended)
Here's link with charts: http://tctechcrunch2011.files.wordpress.com/2012/09/screen-shot-2012-09-03-at-12-20-48.png?w=640&h=555
213.87.131.50 (talk) 19:17, 23 September 2012 (UTC)
- The recession, which is hitting young people (the chief consumer group) especially hard, may have something to do with it. Android phones tend to be cheaper. And it may, of course also have something to do with Android phones actually being superior, and the economic situation is making more people realize... --NorwegianBlue talk 20:19, 23 September 2012 (UTC)
- Android based phones surpassed iPhones in (worldwide) market share some time ago. As NorwegianBlue stated, principally, they are cheaper, much cheaper (as is the case with most non-Apple products). ¦ Reisio (talk) 21:46, 23 September 2012 (UTC)
- But that wouldn't necessarily single Spain out so distinctly from the other countries listed — they're pretty significantly lower there. I wonder if there isn't a difference in what kind of plans they have on offer, too. --Mr.98 (talk) 00:26, 24 September 2012 (UTC)
- If the question is what accounts for the difference of 14.6 between Spain and the next one down, Germany, I dare say that could be a tough question to answer perfectly. Maybe Apple spends less on Spain (due to historical reasons / projections of potential earnings), or maybe they do just think that differently (only a decent poll could confirm this). As for Spain vs the US, I would say Apple being based in the US covers the difference nicely. ¦ Reisio (talk) 00:41, 24 September 2012 (UTC)
- Well, we can all speculate — there are near infinite possibilities in a vacuum of data. Presumably the OP was interested in more than just empty speculation. Things like advertising paid for, plan availability, total numbers sold (are the percentages masking radically different base numbers?), age demographics, and so on, could be possible sources of difference. --Mr.98 (talk) 02:13, 24 September 2012 (UTC)
- Mmm, presumably. ¦ Reisio (talk) 02:20, 24 September 2012 (UTC)
- The OP is apparently from Russia so they probably don't need this but it's perhaps helpful for Americans reading this thread. Phone subsidies are a far less important then they are in US in a lot of the world (0particularly in Asia). In Europe it depends on the country, in some of them they are somewhat common but even then they tend to be less restrictive (i.e. your less likely to need to go with carrier A to get phone X and carrier B to get phone Y because the carrier is subsidising the end user not the developer as seems to happen in the US) and I don't believe they are as important as the US. To put things a different way, the unsubsidised price of the phone generally has a far closer connection to the overall price you pay even if you do get your phone subsidised, then it seems to in the US. People from the US frequently seem to talk about the iPhone being $99 or $199 and a price above $199 being seen as a major barrier to a new phone, which just seems strange to some of us when to get that price you're often signing up for a contract meaning you have to spent at least a couple of thousand and often a fair amount more over the next 2 years. [2] [3] (The first source mentions Spain, in particular it suggests the high tariffs needed for the subsidies caused a dropped in revenue because people turned to using Skype and other VOIP solutions.) According to [4] [5] [6] earlier this year or last year, Spain's two largest carriers dropped subsidies completely because of the high cost to them and the fact they didn't seem to benefit them much (they have very high churn) although the last one does suggest the subsidies pushed people to smart phone from feature phones.
- Prepay is also a more important part of the market, again not as much as in Asia, but far more significant then the US. E.g. [7] mentions the growth of prepay in the US, but it's still only ~25% whereas [8] mentions the growth of contracts in Europe including Spain; and while no overall figure is provided for Spain, one operator is mentioned whose figure is 51% contracts in 2010.
- The graph here for 5 major European countries and Australia [9] is interesting, it shows Android has quite significant dominance in Germany and Spain, in Germany the iPhone is the only other one to have any impact. In all countries bar Italy, Android is growing in relative terms (not unusual of course), in fact the only real one growing, with clear overall declines for iOS. Overall, smartphone penetration in (Western?) Europe is fairly high and Spain has one of the highests penetrations of the big 5 [10] [11], so I don't think the pure numbers are that radically different.
- At a guess from these sources one of the factors, is the nature of the smart phone growth in Spain which seems to have been pushed at least partially by the now dead subsidies. But unlike in the US where this seems to have pushed a relatively expensive phone with expensive plans helped somewhat by the nature of subsidies there, in Spain it's pushed cheaper phones with cheaper plans. The non subsidised portion of the market is of course quite sensitive to the actual price of the phone. BTW, speaking of prices, while I don't know for sure if this applies to Europe or Spain in particular, sources like [12] suggest to me it does. With Android, while there are the phones specifically targetted at the mid range and high mid range, last years models often end up coming to this level. While Apple does sell their older iPhones cheaper, they usually seem fairly expensive compared to older Android phones. In other words, while Apple may be fairly competitive at the high end with their new models, they only really compete lower down on the strength of their brand, interface, app availability, OS updates, etc and even then still expensive enough there is a major portion of the market they can't touch. This [13] is also interesting. While it's commonly claimed iPhone users spend much more then Android ones that source claims Android users actually used more data (iPhone did use more apps), I'm somewhat sceptical of the source since it doesn't even say what country it's referring to and the stupid graphical nature of the source but if true it's an interesting point since carriers obviously don't make money directly from apps except from some carriers still trying the old failed model, whereas they do make money directly from data usage.
- Nil Einne (talk) 06:12, 24 September 2012 (UTC)
- Thanks for digging up some interesting data and bringing more to the conversation than empty guessing! You get the "We're Not Yahoo! Answers" award of the day. --Mr.98 (talk) 14:50, 24 September 2012 (UTC)
- Yes, thanks for not being mediocre like me, Nil. ¦ Reisio (talk) 16:54, 24 September 2012 (UTC)
- Thanks for digging up some interesting data and bringing more to the conversation than empty guessing! You get the "We're Not Yahoo! Answers" award of the day. --Mr.98 (talk) 14:50, 24 September 2012 (UTC)