Wikipedia:Reference desk/Archives/Computing/2012 September 23

{{#ifeq:{{PAGENAME}}|Special:Undelete| |{{#if:|

}} {{#ifeq:{{NAMESPACE}}|Wikipedia|{{#switch:{{NAMESPACE}}|= |
}}|{{error:not substituted|Archive header}}
}}}} {{#if:|
}}
width = "100%"
colspan="3" align="center" | Computing desk
width="20%" align="left" | < September 22

! width="25%" align="center"|<< Aug | September | Oct >>

! width="20%" align="right" |{{#ifexist:Wikipedia:Reference desk/Archives/Computing/2012 September 24|September 24|Current desk}} >

align=center width=95% style="background: #FFFFFF; border: 1px solid #003EBA;" cellpadding="8" cellspacing="0"
style="background: #5D7CBA; text-align: center; font-family:Arial; color:#FFFFFF;" | Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is {{#ifexist:Wikipedia:Reference desk/Archives/Computing/2012 October 3|an archive page|a transcluded archive page}}. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.

__TOC__

= September 23 =

about files in c

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 (talkcontribs) 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)

::::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 [http://msdn.microsoft.com/en-us/library/yeby3zcb%28vs.71%29.aspx]. --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")) http://linux.die.net/man/3/fopen 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

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 (talkcontribs) 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

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?

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

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)