473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

returning/storing string in Arrays

thav
6
I initialized an array,

ArrayName [ ] name = arrayName [100];

with 100 elements.
In the program its taking string data and putting them into the array.
by using Console.Writeline, it asks the user the question.

next I want to take the input and store it in the array.

All I can think of is using the Console.Readline.
but I don't know how to enter it back into an array.

Anyone have any examples of Arrays or links to where I can get more help! Thanks.
Mar 25 '07 #1
4 1352
Roonie
99
ive always used cin/cout for that kind of stuff:
Expand|Select|Wrap|Line Numbers
  1. cout << "Enter your name: ";
  2.   cin.getline (name,256);
will ask the user for their name and take in a line of text from the console.
http://www.cplusplus.com/reference/iostream/istream/getline.html

make sure you include
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
or your cin/couts will have to look like this:
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. std::cout << "Enter your name: ";
  3.   std::cin.getline (name,256);
Mar 25 '07 #2
Roonie
99
or well, cout/cin will send/get text from the console.

you need to figure out how to declare your array to store the information you retrieve that way. what is the type and name of your array again?
Mar 25 '07 #3
thav
6
or well, cout/cin will send/get text from the console.

you need to figure out how to declare your array to store the information you retrieve that way. what is the type and name of your array again?

its a string and the Arrayname is Contact.

In this program I created 3 class,

1 is Contact to keep the contact information.
such as first and last name, phone number.

2 is the ContactManager class to handle the details of the information.
<this is the area I am needing help on>



3 is the Program class with the main method, that will display 3 options.
of adding and listing class.
Mar 25 '07 #4
Roonie
99
so ContactManager is what stores the information into Contact objects?

why dont you add member functions to the Contact class to do this? and if you want to store a string, use a string to store it in.
Mar 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Gent | last post by:
I have two questions which are very similar: Is it possible to return an object in C++. Below is part of my code for reference however I am more concerned about the concept. It seems like the...
1
by: john | last post by:
Relatively new to C coding, so any help would greatly be appreciated. I'm having problems try to return my string array from my parsing function. When I do a printf I am getting the correct value...
10
by: Pete | last post by:
Can someone please help, I'm trying to pass an array to a function, do some operation on that array, then return it for further use. The errors I am getting for the following code are, differences...
3
by: Carramba | last post by:
hi! the code is cinpiling with gcc -ansi -pedantic. so Iam back to my question Iam trying to make program were I enter string and serach char. and funktion prints out witch position char is...
9
by: CptDondo | last post by:
I am working on an embedded platform which has a block of battery-backed RAM. I need to store various types of data in this block of memory - for example, bitmapped data for control registers,...
5
by: shyam | last post by:
Hi All I have to write a function which basically takes in a string and returns an unknown number( at compile time) of strings i hav the following syntax in mind char *tokenize(char *) ...
20
by: Martin Jørgensen | last post by:
Hi, I'm reading a number of double values from a file. It's a 2D-array: 1 2 3 4 5 6 7 ------------- 1 3.2 2 0 2.1 3 9.3 4
8
by: jodleren | last post by:
Hi! I have a function, a part of my code which I can use as a function. It will return 2 arrays, and I am wondering what way to do so. Both arrays hold strings, there are no special keys. 1)...
8
by: darren | last post by:
Hi everybody, have a quick look at this code: ===== ===== int main(void) { string msg; makeString(msg); cout << "back in main, result = " << msg << endl;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.