teamsilvamma's Profile User Rating: -----

Reputation: -2 Dishonored
Group:
Active Members
Active Posts:
144 (0.28 per day)
Joined:
17-January 12
Profile Views:
985
Last Active:
User is offline Jun 05 2013 06:11 AM
Currently:
Offline

Previous Fields

Country:
BR
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
Playstation
Your Car:
Dodge
Dream Kudos:
0
Icon   teamsilvamma has not set their status

Posts I've Made

  1. In Topic: Last name is not returning

    Posted 4 Jun 2013

    View Postjimblumberg, on 04 June 2013 - 02:56 PM, said:

    Glad you've got it working. I have a couple of suggestions. First think about more functions. Try to make each function do one thing. For example a function to retrieve the information from the user and another function to validate and convert the information.

    Also you may want to look into using a stringstream to process your string. For example:

    /* Function to convert a name from Last, First MI. to First MI Last.
       Demonstrates basic usage of both the istringstream and ostringstream classes. */
    std::string convertName(const std::string& name)
    {
       std::istringstream fin(name);
       std::string first, middle, last;
       getline(fin, last, ','); // Get the last name.
       fin.get(); // get and throw away the leading space character.
       getline(fin, first, ' ');  // Get the first name.
       getline(fin, middle); // Get the middle initial.
    
       std::ostringstream fout;
       fout << first << " " << middle << " " << last << std::ends;
       return(fout.str());
    }
    
    


    Jim


    You're absolutely right. The tutorial exercise wanted me to do it like this ( a string class manipulation tutorial) but I do like your code better and I will save this chunk of code and experiment with it. Thanks a lot man.
  2. In Topic: Last name is not returning

    Posted 4 Jun 2013

    I actually rewrote the code and it is clean and working perfectly now.

    #include <iostream>
    #include <string>
    #include <sstream>
    
    using namespace std;
    
    void inputData(string &); //Declare Call-by-reference function
    void outputData(string); //Declare Call-by-value function
    
    int main() {
    
        //declare variables
    	string myString;
    	inputData(myString);
    	outputData(myString);
    }
    
    void inputData(string &myString) {
        cout << "Last, First, MI: ";
        getline( cin, myString ); //accept string in requested format Last, First MI
        string first, middle, last, fullname;
    
        //instantiate the values for commas and spaces
        string comma = ",";
        string space = " ";
    
        //find the location of the comma and the spaces in the string
        int commaFound = myString.find(comma);
        int firstSpace = myString.find_first_of(space);
        int lastSpace = myString.find_last_of(space);
    
        myString.erase (commaFound, 1); //erase 1 place from where the comma is found
    
        last = myString.substr(0, commaFound); //isolate the last name
        first = myString.substr(commaFound + 1, firstSpace - 2); //isolate the last namme
        middle = myString.substr(lastSpace, -1); //isolate the middle initial
    
        //takes the lenght of the word and inserts a space at the end of it
        unsigned pos = first.length();
          first.insert(pos,space);
        unsigned pos2 = middle.length();
          middle.insert(pos2,space);
    
        myString = first + middle + last; //Pass-by-reference
    
    }
    
    
    void outputData(string myString) {
        cout << myString<< " by value " << endl; //Pass-by-value
    }
    
    
    
  3. In Topic: Last name is not returning

    Posted 3 Jun 2013

    View Post#define, on 03 June 2013 - 07:01 PM, said:

    Hi, here you have two statements reading into myString. The first statement reads a word (upto the space), into the string. The second statement reads the rest of the line into myString, overwriting any data in the string.

    20	    cin >> myString;
    21	    getline( cin, myString );
    
    


    Interesting. I failed to see that. Ok, I deleted the cin and now I'm getting the string in the same order it was put in. but that's another question I guess. I'll brainstorm and repost if I can't figure it out.

    Thanks
  4. In Topic: login in form

    Posted 15 Feb 2013

    View Postandrewsw, on 15 February 2013 - 01:37 PM, said:

    View Postteamsilvamma, on 15 February 2013 - 06:50 AM, said:

    That would make sense actually, I had someone test my files and said they worked fine, but I was confused because they don't when I try. ...so you are saying they will only work when the site is live?

    You can test your site locally if you install one of the XAMPP, WAMP or LAMP stacks, as I mentioned already; there are others as well. I haven't provided links as you can find them easily through Google or another search engine :)/>

    I find it extremely hard to believe that you "spent a year messing around" and haven't come across these terms. If you picked up a book, or went through a short tutorial, you are bound to come across these terms.

    A year on and off. I mean, having a members area is something I wanted, but not needed. Whenever I came across things I knew I didn't know right off the bat, I left it alone.

    On a good note, I contacted the host and they examined my files and explained what happened. It was the connection settings in the config.php file

    Thanks tho. I will look into this you're talking about
  5. In Topic: login in form

    Posted 15 Feb 2013

    Ok, I'm getting closer. I am getting this when I try to log in or set up an account

    "Failed to connect to server: Access denied for user 'lotusadmin'@'localhost' (using password: YES)"

    Is it because I have to define the host in the config file? If that is the case, how do I find that information? is it their url, proxy, dns address,...?

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Sao Paulo, Brazil

Contact Information

E-mail:
Click here to e-mail me

Friends

teamsilvamma hasn't added any friends yet.

Comments

teamsilvamma has no profile comments yet. Why not say hello?