Jump to content

Wikipedia:Reference desk/Archives/Computing/2006 September 3

From Wikipedia, the free encyclopedia
< September 2 Computing desk archive September 4 >
Humanities Science Mathematics Computing/IT Language Miscellaneous 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 at one of the pages linked to above.

C++ functions

[edit]

Hello! I have three questions:

  1. First of all, I'd like to know if I'm allowed to ask someone to write a C++ function for me, provided it's reasonably short, of course!
  2. If the answer to the first question is yes, then could somebody write me a function that counts how many lines a file has? (I imagine you would have to count the newline characters, '\n' )
  3. If the answer to the first question is no, then could anyone tell me where I might find a function that counts the lines of text in a given file? (like in stdlib.h, for example)

--Thor Waldsen 01:27, 3 September 2006 (UTC)[reply]

hi i dont know too much but basically the gist is, you call a filereader function and open the file or whatever (i dont know if youre a student or what but your book should explain this, or just check a website for opening text files in c++), and then im sure thers some sort of function that gets the next line, and some function that sees if it has a next function... so something in a psuedo codejava would be:
int n = 0;
blah = open file(file.txt);
while(blah.hasNext())
{
n++;
blah.Next();
}
return n;
good luck Modesty84 01:44, 3 September 2006 (UTC)[reply]
here is a text file reading program. you just need to swap out the while statement to something like what i wrote above. http://www.fredosaurus.com/notes-cpp/io/readtextfile.html Modesty84 01:48, 3 September 2006 (UTC)[reply]
I'll look into it. Thanks a lot!! --Thor Waldsen 02:04, 3 September 2006 (UTC)[reply]
Look for the source for the wc Unix utility, it must count lines, characters, words; other implementations may add extra things. This will be in C, you could try porting it to C++ if you're knowledgeable in both languages. Dysprosia 02:09, 3 September 2006 (UTC)[reply]
I suspect that that may be a little too elaborate for our friend's current state of knowledge about C++. wc, simple though it is, contains extra functionality of little interest. I think he needs to read up on the "iostream" library, as well as while loops in C++. --Robert Merkel 02:23, 3 September 2006 (UTC)[reply]
Perhaps, but it would be a good pedagogical exercise, if Thor was well acquainted with C. Dysprosia 10:44, 3 September 2006 (UTC)[reply]

If using an fstream you can just getline (counting each time) until end of file (eof). - Rainwarrior 04:33, 3 September 2006 (UTC)[reply]

Real Player for Mac

[edit]

How can I create a playlist and maintain a library in Real Player for Mac? I have the latest version.--202.161.131.76 02:31, 3 September 2006 (UTC)[reply]

Very simple solution, get a real (no pun intended) media player, such as MPlayer.--Frenchman113 on wheels! 16:05, 3 September 2006 (UTC)[reply]

PROCESSOR

[edit]

Hi, I have an AMD GA-K8VM800M motherboard with an AMD Athlon64 2800+ 1.8GHZ (Socket 754). I'm thinking of upgrading the processor with an AMD Sempron 3300+. I would like to know how fast and how this pro. will perform as a media/gaming PC. I would like to know your opinions. Can u recommend any other processor that will perform well with this m/b for gaming/media? THANKS JON.

what game(s) and what kind of video card and ram do you have? dont know mucha bout that processor but seems like anythin could be a upgrade. Modesty84 07:49, 3 September 2006 (UTC)[reply]

I have 1GB DDR400 ram, 120GB SATA HDD, a 256MB Sapphire ATI 9550 “AGP” VGA Card. JON--203.122.73.26 07:59, 3 September 2006 (UTC)[reply]

yea i dont relaly know enough about hardware to give you any real advice. i guess the processor would be the weakest link in that equation. maybe someone else can help you, good luck with it :> Modesty84 08:02, 3 September 2006 (UTC)[reply]

To me,this configuration looks not that bad to suffice most of the any game needs these days....A friend of mine has the same series as yours,but with a different M\B model.He could hit through all sort of games.Tried any 3d bench marks?...Do it first and look for an upgrade if ever needed before investing money..or try playing any high graphics demanding games and check out for a decent frame rates....All the Best

I'm not sure if it would be worth upgrading - the Semperon is a cut-down version of an Athlon 64 and while the clock rate is higher there's probably less cache. Robmods 15:46, 3 September 2006 (UTC)[reply]
I have a AMD Athlon 64 3000+, which coupled with a good graphics card can run just about current game. I'd be wary about getting a Sempron: you might well be better off with your slower Althon 64, because it will outperform it in highly demanding apps like games and media software (probably, I haven't checked the numbers). Either way, it's not going to be a big perfomance leap. I'd recommend you save your money to get a Athlon 64 between 3400-4000, which is an increase you'll notice. Also, while your memory and hard drive are fine, you will benefit a lot more from a newer graphics card. Personally I'd recommend an AGP Geforce 6600GT or 6800 if you want to upgrade. If money is no object, then the Geforce 7800GS is the fastest AGP card available. Sum0 11:14, 4 September 2006 (UTC)[reply]

Various navigational issues.

[edit]

I am using an IBM T30 laptop with WinXP pro. The trackpad broke a while back and is disabled. My first inclination is to suspect hardware problems with the trackpoint. Anyhow, mouse clicking does not work, but mouse movement (via trackpoint) does work. The keyboard seems to work, but the top menubars in programs, when selected via alt+option, don't open. I tried tabbing over to the start menu to fiddle with the control panel but, though I was able to navigate to the options in the control panel, attempting to open the options themselves with the enter key failed to work. Any guesses as to what is wrong?

--128.113.107.52 07:48, 3 September 2006 (UTC)[reply]

does the enter key work in other situations? Modesty84 07:51, 3 September 2006 (UTC)[reply]

-- Yes.

do you have anything important saved on the computer? i would just reformat it and see if that helps Modesty84 07:59, 3 September 2006 (UTC)[reply]

-- That's something I reserve for a last resort.


Odd side note: When navigating the file system, the top menus all open via alt, but using the down/up keys to navigate the options works only in the case of the favorites menu. The items in the favorites menu cannot be opened with the enter key, though. Strange.

could be a worm maybe try start->search-> *.cpl results are the control panel options Modesty84 08:09, 3 September 2006 (UTC)[reply]

My original suspicion about hardware problems were correct. Somehow my trackpad re-enabled itself. Thanks for pointing out the file extension of the control panel options. Disabling the trackpad again fixed everything.

Get a new laptop man, t30 is old! --Froth 23:02, 8 September 2006 (UTC)[reply]

Google results not the same for everyone?

[edit]

If one enters a search in Google, do the results depend on location? On the science ref desk I placed links to two searches and got 538 and 886 results respectively. When someone else clicked those links he got 362 and 348 results. Quite a big difference. I'm from the Netherlands and he is from the US. Might that explain it? DirkvdM 14:00, 3 September 2006 (UTC)[reply]

I think it's the traffic that hits...we actualy did the same sort of search from the same location,but ended up like what you experienced.But it wasn't quite common for all your searches.I'm not sure though there might be a valid reason other than this...let's wait for others....User:202.56.231.116

It might be interesting to keep some records of the differences, maybe also see if the results were different. We know the Chinese results are censored. If the requests are going to the same machines at Google HQ, the results should be the same whether they're returned to US or Europe or wherever. Rentwa 16:02, 3 September 2006 (UTC)[reply]

I got 503 and 859, respectively. I also live in the US. --Yanwen 17:16, 3 September 2006 (UTC)[reply]

I tried again and now I get 538 (same) and 823 (less). Now I can understand such small differences (after all the Google database gets updated al the time), but 362 and 348 are really different, the second one even much less than half. DirkvdM 17:43, 3 September 2006 (UTC)[reply]

I get 538 and 823 using the links. Changing '.com' to '.co.uk' in the address bar I get 538 (same) and 860 (different). Rentwa 17:50, 3 September 2006 (UTC)[reply]

Reason 1: Some results are removed due to local laws: search for a ...uh, "controversial" organization in The Netherlands vs Germany. But that's unlikely to be the cause in these searches.
Reason 2: google isn't one big computer, it's distributed and your query gets routed to the closest copy of Google. The indexes in the different copies are not completely in sync.
Reason 3: (what I'm guessing is happening here): the "someone else" looked at unique hits. Google has an algorithm that looks at two pages and if they are similar enough Google lists them as "very similar". The 886 count includes duplicates, the 348 doesn't. Keep clicking "next result page" until you come to the end or go directly here: [1], see the "omitted some results" message at the bottom of the page.
(Aside on a common misunderstanding of unique results: uniqueness only considers the first 1000 pages. If you search for "microsoft"[2] you'll be surprised that only about 130 unique web pages in the whole world contain the word "microsoft". Of course there are more. The way the duplicate remover works it takes the first 1000 results and figures out which of those are duplicates. Only 130 of the first 1000 are unique.) Weregerbil 19:31, 3 September 2006 (UTC)[reply]

I believe the "Omitted search results" are still counted in the total, just not listed individually, until you pick that link. StuRat 21:35, 3 September 2006 (UTC)[reply]

I'm the one getting the lowest number of hits, I wonder what's so different for me. I'm actually clicking on the links, not retyping them myself. I also checked to see that I have "Safe Search" turned off, so should get all result listed, right ? StuRat 21:23, 3 September 2006 (UTC)[reply]

I'm voting for Dirk anyway - dangerous looking type. Rentwa 00:33, 4 September 2006 (UTC)[reply]
In real life I've got pacifist tendencies (unless you piss me off, that is :) ), but in the virtual realm, where only argumentation counts, I can be quite vicious. My results when I look at the last page is StuRat 459 and DirkdM 550. With strict filtering on, for StuRat I get 511 on the first page and 440 on the last one (although it says 'results 301 to 396' - now which is it?). For DirkvdM I get 767 on the fist page and 523 (or 466) on the last page. So we on't use any rude language according to Google? We must try harder then. :) Also, considering the way Google works, maybe the number of hits on one page matters? I've got that maxed out at 100. DirkvdM 06:44, 4 September 2006 (UTC)[reply]
Mine was set to 100, too. StuRat 07:34, 4 September 2006 (UTC)[reply]
It can also do with personalized search results. --Proficient 17:55, 4 September 2006 (UTC)[reply]
How so ? StuRat 04:54, 5 September 2006 (UTC)[reply]

Odd behaviour in control panel

[edit]

I'm running XP with service pack 2, and have recently noticed that the menu items in control panel (I use the 'classic' version for the start menu, so it looks like win2000) used to be in alphabetical order, but now start with 'Power options', then go in alpha aorder until 'wirelss...', then start with items beginning with 'a' etc. This isn't a problem, just curious behaviour, and I wonder if anyone else has seen anything similar? Madmath789 14:07, 3 September 2006 (UTC)[reply]

Right-clicking and selecting 'Arrange Icons by' and then 'Name' should put them back in order. Robmods 19:06, 3 September 2006 (UTC)[reply]
Thanks - that gets them back into order, but the real questions is: "why did they ever get put into a different order at all?" Madmath789 19:59, 3 September 2006 (UTC)[reply]
They might be listed in order of creation date or last modification date, which is admittedly quite a useless order for the control panel. StuRat 21:18, 3 September 2006 (UTC)[reply]

putting iPod on a new iTunes

[edit]

is there anyway i could stop the iPod from losing its songs when i put it onto a new iTunes. or would it just be easier to move the songs from my old computer onto my new one?

thanks--Crab People 15:04, 3 September 2006 (UTC)[reply]

yea, crack the drm on the tunes, try... hymn for v5 and earlier, or http://hymn-project.org/forums/viewtopic.php?t=1553 . Remember, this is illegal in the USA, and immoral if you don't own the music.--Frenchman113 on wheels! 15:10, 3 September 2006 (UTC)[reply]

Websites hosting cracks and serials

[edit]

Hi friends....I have been having this doubt for a very long time....There are some websites hosting cracks and serials for the original software which you may come across when you just google net,as you may be aware of this..Now isn't this something illegal?...Why won't they get arrested? and what still makes them to reverse engineer and release these stuffs?.Can't their websites be identified and the members hosting be traced down and arrested?....A friend of mine said that if a software release was in one country then the cracks or serials for that software would be released in a website belonging to some other country and hence it can't be arrested or banned..Is it true?...Sorry if it sounds too basic or stupid,I'm just a rookie in this....Any info?

Try Topsite (warez). Yes, this is very illegal, but the servers are well hidden and protected. Also, we have an article on reverse engineering, a lot of cracks are done with a disassembler/hex editor/debugger. On a side note (and not to be mean), you could read Wikipedia:Tutorial and learn to write legibily.--Frenchman113 on wheels! 16:04, 3 September 2006 (UTC)[reply]
"cracks" I understand, but "serials"? —Tamfang 23:50, 3 September 2006 (UTC)[reply]
I presume serial is a form obtained from cracking a software...Using a serial crack is different from other types of cracking....Correct me if I'm wrong..
Oh, silly me, to activate some software you need the serial number from the package ... —Tamfang 05:58, 4 September 2006 (UTC)[reply]

Photoshop Keygen

[edit]

Does anyone know a website or place where I can download a spyware, adware free Photoshop CS2 Key Generator? Jamesino 20:17, 3 September 2006 (UTC)[reply]

http://store.adobe.com/ --Kjoonlee 03:29, 4 September 2006 (UTC)[reply]
You are going to have to download a whole pacage, then just take the keygen. Try a torrent site. — [Mac Davis] (talk) (Desk|Help me improve)
before you resort to stealing, try free alternatives such as GIMPshop. Jon513 13:26, 4 September 2006 (UTC)[reply]
Why would you download software illegally? --Proficient 17:57, 4 September 2006 (UTC)[reply]
Aside from the legality aspects, Photoshop CS2 requires you to activate the software as well, so a keygen might not work. --Canley 07:10, 5 September 2006 (UTC)[reply]
Oh it works. There's such thing as "phone activation" where you call a number, touch in a code that appears on your computer, and then listen for a returning code, which you type in a box. But instead of using the phone to transform that code, use the keygen. look for the PARADOX gen, it's clean and works --Froth 20:39, 8 September 2006 (UTC)[reply]

CMM level

[edit]

who will given the certification that a company is following all the CMM levels?

Have a look at the links from Capability Maturity Model. --Robert Merkel 23:17, 3 September 2006 (UTC)[reply]

Input non-English text

[edit]

I am using Windows XP and i set in the Regional and Language settings to allow me to use a Spanish keyboard setting in addition to the english one. My keyboard is labeled to the english setting, though, and I ave no way of knowing which key is which in the spanish setting other than by trying it. Is there a way to get an on-screen keyboard or something that shows which key is which for the spanish setting? Thanks! --Life 23:15, 3 September 2006 (UTC)[reply]

Python: how can you use the arrow keys as a user input?

[edit]

I'm writing a basic text editor as an exercise to learn python, and I need a way to position the "cursor" (where the inputted text is inserted) -- using w/a/s/d as a substitute for the arrow keys isn't an option because these are required if the user wants to type "w","a","s" or "d", obviously.

Accepting user input for text is easy -- just use raw_input(), but whenever I use raw_input() it doesn't seem to want to accept the arrow keys as a valid input.

Every time I type an arrow key in the python interpreter I get ^[[C so I wrote the following program to see if I could use this:

  variable = raw_input("Press the right arrow key: ")
  if variable == "^[[C":
      print "you pressed the right arrow key"
  elif:
      print "you didn't press the right arrow key"

but this doesn't work in practice.

Any ideas, or links? I imagine that I'll need to import a module of some kind, but with so many python modules available I couldn't find the documentation for one that I could use.

Thanks for the help.

I don't know Python, but the arrow character isn't the string consisting of characters '^', '[', '[', 'C', it's going to be a nonprintable control character, much like "^M" is used to represent the enter key. Dysprosia 01:49, 4 September 2006 (UTC)[reply]
raw_input() isn't the right thing to use anyway, as it's still "line oriented" (you won't see the keypresses, even special ones like arrow keys, until someone presses enter). You want to use the getch() function, which is part of a given platform's console package. Here's some basic code for windows:
import msvcrt

while True:
    c = msvcrt.getch()
    charcode = ord(c[0])
    print "char %c,%d" % (c,charcode)

    # if the key is 27, the ESC key, then quit
    if charcode == 27:
        break
(you'll notice some keys, like the arrow keys, send two charcodes for every keypress - so you'll need to write something to handle that).
For unix/linux/posix etc you can use the "curses" console IO package. It's a bit higher-powered (at the expense of being a bit harder to program). Here's a program that detects the left and right arrow keypresses:
def display_message(s, msg):
    s.addstr(1,0, "%-20s"%msg)

import curses
scr = curses.initscr()

# set some stuff so we get more direct access to keystrokes
curses.noecho() # don't echo the chars I type
curses.cbreak() # tell me immediately when keys are hit
scr.keypad(1) # handle fancy keypresses in curses
scr.addstr(0,0, 'hit f1 to exit')

while True:
    c = scr.getch()
    # for codes see http://docs.python.org/lib/node267.html
    if c==curses.KEY_LEFT: display_message(scr, 'left')
    elif c==curses.KEY_RIGHT: display_message(scr, 'right')
    elif c==curses.KEY_F1: break
    else: display_message(scr, 'code=0x%x' % c)

# restore the terminal to the way it was before we changed it
curses.nocbreak()
scr.keypad(0)
curses.echo()
curses.endwin() # bye
If you're planning on writing a text editor in unix, use curses for the output too (so you can put text right where you want it on the screen). For windows, you'll need to find a ANSI terminal package like this one which will move the cursor around in the way you'd want. -- Finlay McWalter | Talk 11:36, 4 September 2006 (UTC)[reply]
As I note above, if you're doing a text editor then curses is the easiest way, as it does a lot of window handling and text positioning stuff for you. The flipside is that you can't use normal terminal io when you're using curses. If you just wanted to get the raw keys, but didn't want curses' other features, you can use the more basic termios system (on which curses relies). Here's a basic example using just termios:
import termios,sys

stdin_fd = sys.stdin.fileno()

# turn off echo and turn on ICANON mode
attrs = termios.tcgetattr(stdin_fd)
attrs[3] = attrs[3] & ~termios.ECHO   # disable ECHO
attrs[3] = attrs[3] & ~termios.ICANON # get chars immediately
termios.tcsetattr(stdin_fd, termios.TCSADRAIN, attrs)

while True:
    keys = sys.stdin.read(1)
    print "char %c,%d" % (keys[0],ord(keys[0]))
    if keys[0] == 'q': # exit on q
        break
    
# return terminal to normal
attrs[3] = attrs[3] | termios.ECHO   # reenable ECHO
attrs[3] = attrs[3] | termios.ICANON # disable ICANON
termios.tcsetattr(stdin_fd, termios.TCSADRAIN, attrs)
Granted, the termios lines are a tad arcane, but other than that it's much the same as the windows version. -- Finlay McWalter | Talk 15:31, 4 September 2006 (UTC)[reply]