Someone PLS Help

This is a discussion on Someone PLS Help within the C++ Programming forums, part of the General Programming Boards category; My problem is i want to change each number in string to character that i had assigned as char something[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";. ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    71

    Someone PLS Help

    My problem is

    i want to change each number in string to character that i had assigned as char something[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";.
    for people who dont understand what i mean, here is an example,

    array[0]=44, array[1]=11, array[2]=00, array[3]=13, so this is the fomula tat i want to use :
    output for 44 is (44-26)+65 = 83, for character 83 = s, for 11 is 11+65 = 76 is character L, 00 is A because 00+65, and the last is 13 + 65 = 78 which is N.

    the final output will be S L A N.

    Code:
    int ifEven(string str)
    {
        string array[15];
        char something[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    	int i=0;
    	int k=0;
    	
        while(i<str.size()-1)
        {
            array[k]=str.substr(i,2);
    		cout<<array[k]<<" ";
    		i+=2;
    		k+=1;
    	} 
       
    
    }

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    85
    Bit of a vague explanation for me, can you give us a better example

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,761
    > My problem is
    That you've asked basically the same question a dozen times, and haven't paid any attention to any of the replies.

    Nearly 100 replies to all your threads so far, surely someone must have stubled onto some kind of an answer. Even if they didn't, there's going to be a clue in there for you to work with.

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    71
    well, i just want to display a character of string from the number of string...

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Last edited by 7stud; 12-10-2005 at 08:51 AM.

  6. #6
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    ...also cross posted on other forums.

  7. #7
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    Quote Originally Posted by gtr_s15
    well, i just want to display a character of string from the number of string...
    Code:
    char string[100];
    char character = string[number];
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  8. #8
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Quote Originally Posted by 7stud
    ...also cross posted on other forums.
    Yeah...can we get a few locked down so that we're not all replying to different threads?
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  9. #9
    Registered User
    Join Date
    Dec 2005
    Location
    the Netherlands
    Posts
    5
    Code:
    #include <iostream.h>
    #include <string.h>
    
    using namespace std;
    
    int main ()
    {
    	int i, n;                                                     NOTE, that the site breaks the alphabet[] string (repair it)
    	char alphabet[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\?!@#$%^&*(),.-_+=:<>/\\\'\"\t "; //assign A to alphabet[0], B to alphabet[1], etc.
    	string input, store;
    	
    	getline (cin, input); //get input, note that you can also use getline for file input.
    	
    	int input_length = input.length (); //store string lenth, since it will be modified
    	
    	for (i = 0; i <= input_length; i++)
    	{
    		if (input.compare (0, 1, " ") == 0) //perforem a function, when a space is found, note that the last number will not be shown here.
    		{
    			n = atoi (store.c_str()); //assign the input number to a int.
    			cout << alphabet[n] ; // display alphabet[number].
    			
    			input.erase (0, 1); // erase the space
    			store.erase (); //erase store so you can use it again.
    		}
    		
    		store.append (input, 0, 1); //store one number at the time.
    		input.erase (0, 1); //erase the number that you assignd to the store string.
    	}
    	
            n = atoi (store.c_str());
    	cout << alphabet[n] << endl; //show the last number
    }
    So, if I input 07 30 37 37 40 88 22 40 43 37 29 63, I get "Hello World!"
    Last edited by StOnEwAlL; 12-11-2005 at 03:34 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic port scanner code .. pls help ???
    By intruder in forum C Programming
    Replies: 18
    Last Post: 03-13-2003, 08:47 AM
  2. i dont know what to do. pls. help!!!!
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 03-14-2002, 03:24 PM
  3. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 10:46 AM
  4. pls help me!!
    By hanseler in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2001, 08:46 PM
  5. Pls Help Me In This Question!!!
    By Joanna in forum Windows Programming
    Replies: 1
    Last Post: 10-20-2001, 03:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21