strings into array

Posted on 2005-04-17
Last Modified: 2010-04-01
if i have a list of names

jackson, joe
davis, bill

how could i put each one of the names into arrayx[]?

Question by:Kal130
    1 Comment
    LVL 30

    Accepted Solution

    Hi Kal130,
    You can use a vector of strings.

    #include <vector>
    #include <string>
    #include <iostream>

    std::vector<std::string> MyArray;

    MyArray.push_back("jackson, joe");
    MyArray.push_back("davis, bill");

    std::cout << MyArray[0] << std::endl;
    std::cout << MyArray[1] << std::endl;
    std::cout << MyArray[2] << std::endl;

    David Maisonave :-)

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
    This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now