home   |   contact us   |   sitemap   |   advertising Free Online Games
Free MMORPG

The Free MMORPG Games- Free MMORPG - P2P Games - Open Beta - Closed Beta - Browser Based - Non-English - Other Free Games - Top 50


Go Back   Onrpg Free MMORPG Forums > Development > General Programming

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-21-2007, 07:19 PM   #1 (permalink)
Banned
 
Join Date: Oct 2007
Posts: 54
MMOFaces Profile: None Yet
Default extracting letters from string

Can someone tell me how to extract each letters out of a string in order?

like cin>>Sentence1;

inputs:hi whats up

how would you extract each letter and be able to reuse them invididualy? I would like to make a translator from binary to english/english to binary. Would this require an array?
imaguni is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-21-2007, 09:53 PM   #2 (permalink)
Retired Staff
 
TwitcH's Avatar
 
Join Date: May 2006
Posts: 2,026
MMOFaces Profile: None Yet
Default

hrm, I can show you a quick example in C, but I dont have time to explain it yet

Code:
#include <stdio.h>
#include <unistd.h>
int main (void) {
        char *ptr = "Hello, World";
        for (int i = 0; *(ptr + i); i++) {
                putchar(*(ptr+i));
                fflush(stdout);
                usleep(500000);
}
putchar('\n');
}
If I get time I'll explain each part to you.

Hope it helps =/
TwitcH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-22-2007, 02:21 AM   #3 (permalink)
Banned
 
Join Date: Oct 2007
Posts: 54
MMOFaces Profile: None Yet
Default

The only thing i understood about that is that you're doing a for loop ^.^

If you have the time please explain what each thing is doing.
imaguni is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-22-2007, 04:05 AM   #4 (permalink)
Snakes Big Toe
 
Eriond's Avatar
 
Join Date: May 2006
Location: Canada
Posts: 445
Reputation: 17
Send a message via MSN to Eriond
MMOFaces Profile: None Yet
Default

Well, okay, I'll explain what TLM did, and I'll simplify it. (And won't that run into a segmentation fault, because you're running off the end of array there?)

Code:
int main()
{
      char Line[] = "Hello World!\0"
      for (int C = 0; C < strlen(Line); C++)
            cout << "Character " << C << ": " << Line[C] << endl;
      return 0;
}
Basically, what you're doing here is looping through a character array, until C is greater than or equal to strlen(Line) (which is a function that tells you how long a string is, if it's terminated by a null terminator character, the \0 there.), and then printing every character in the string to the terminal. Each individual character can be accessed by specifying exactly where in the array it is. So for example.

The character 'H' is Line[0]. The Character 'W' is Line[6].

Alterinatively, if you want to do it with cin, and get the user's input, you can write the first line of the program (the Line[], line), like this:

Code:
char Line[100];
cin >> Line;
And keep the rest of the program as-is.

Hope that answers your question!
__________________
This was a triumph. I'm making a note here, HUGE SUCCESS.

Outsider
3D Space Shooter/RPG in Development
http://advena.awardspace.com/
Eriond is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-23-2007, 12:48 PM   #5 (permalink)
Retired Staff
 
TwitcH's Avatar
 
Join Date: May 2006
Posts: 2,026
MMOFaces Profile: None Yet
Default

Yeah I just read the OP again and that really wasnt a good example I gave

Sorry about that, it was sort of the same thing, mine would print each letter of the string individually with a small pause between each character, plus it was quick dirty C with pointers and *nix commands

So yeah, ignore my example if you wish to stay sane.

I gotta stop posting in here, i'm gonna confuse all the C++ kiddys.

Last edited by TwitcH; 10-23-2007 at 12:52 PM.
TwitcH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-23-2007, 11:18 PM   #6 (permalink)
Banned
 
Join Date: Oct 2007
Posts: 54
MMOFaces Profile: None Yet
Default

lol its ok, thank you both of you.
imaguni is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:38 PM.

Forums Section List
Main Category Free Games Online Games Upcoming Games Online Games Upcoming Games
General Free MMORPG Fiesta Online    Maple Story Guides Trickster DOMO - Dream of Mirror Online
RolePlaying Free MMO & MMOFPS Conquer Online    Maple Story Buy/Sell/Trade WarRock Online Seal Online
Newbie Zone Korean/Foreign Games DragonGem Lunia World of Warcraft Age of Armor
  Browser/MUDs FlyFF Ragnarok Online Other Games Exteel
  Single Player RPGs Ghost Online Rakion    Rappelz Infinity
  Free MMORPG Requests Guildwars Runescape    Final Fantasy XI Cabal Online
    Gunz Online Scions of Fate (YulGang)    Goonzu Online Granado Espada
    Maple Story Silkroad    Gunbound Nostale



Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Onrpg, Copyright ©2003-2007, BlueCastle Media

Copyright © 2004-2007 BlueCastle Media