473,324 Members | 2,456 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,324 software developers and data experts.

Enter data into an array with C++

hello i am aresearch scholar .i am workingon matrice3s so i want to know that how i can enter a text data FILE in to array in c++ programming.

if form of text file are like.

9 8 7 5 6 2 4 1 3 4 23 36
3 6 2 3 6 2 5 2 3 3 6 89
5 6 8 9 7 2 3 1 36 56 63
Sep 14 '07 #1
4 3801
Nepomuk
3,112 Expert 2GB
hello i am aresearch scholar .i am workingon matrice3s so i want to know that how i can enter a text data FILE in to array in c++ programming.

if form of text file are like.

9 8 7 5 6 2 4 1 3 4 23 36
3 6 2 3 6 2 5 2 3 3 6 89
5 6 8 9 7 2 3 1 36 56 63
Hi Drsunil76! Welcome to TSDN!

Please ask your question in the C++ Forum, not in the Café.

Greetings,
Nepomuk
Sep 14 '07 #2
sicarie
4,677 Expert Mod 4TB
hello i am aresearch scholar .i am workingon matrice3s so i want to know that how i can enter a text data FILE in to array in c++ programming.

if form of text file are like.

9 8 7 5 6 2 4 1 3 4 23 36
3 6 2 3 6 2 5 2 3 3 6 89
5 6 8 9 7 2 3 1 36 56 63
Sounds like you need file IO.
Sep 14 '07 #3
ilikepython
844 Expert 512MB
Sounds like you need file IO.
I think the best option is to use getline() and then iterate over the string and enter into the array from the string.
Sep 14 '07 #4
sicarie
4,677 Expert Mod 4TB
I think the best option is to use getline() and then iterate over the string and enter into the array from the string.
If the OP's sure that's how the input will come in all the time, the OP can use cin. That just won't make it very robust/flexible...

It just depends on who is going to be using it and for how long. If it's just to run this single simulation and you're sure all the data is only separated by spaces, then I'd recommend cin - it's easy, you don't have to worry about too much. But if multiple simulations are going to be run (like if you do other experiments later and want to use this sort of input method to run some other calculation), I'd agree with ilikepython and say use getline().
Sep 14 '07 #5

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

Similar topics

1
by: Susan | last post by:
I have a bound form and subform and am trying to enter the data in both forms programatically. The Linkmaster and Linkchild properties are set. My intent is to be able to look at the data before it...
13
by: Rick | last post by:
The following code will enter an infinate loop when in ReadChars. I can only make it happen when reading a Stream and with this particular XML. If I use the ReadInnerXml call rather than my own...
5
by: cameron | last post by:
I am working on an assignment where I have to allow end-users to enter in data and to have C++ make a calculation. From there I have to set up a loop to allow users to go back and enter new data or...
8
by: Dan Holmes | last post by:
I am receiving data from the stream of a socket. I am trying to determine if the user pressed the Enter key. The buffer has 2 non-zero bytes when the user presses enter: 13 and 10. If i...
4
by: portCo | last post by:
Hello there, I am using Visual Basic 2005. I want to store a value when I press enter key on the keyboard. Could anyone help me out? Thanks alot.
24
by: MichaelK | last post by:
Who knows how to prevent submitting a form on the press Enter button before all fields on the form are filled up. People just enter the first field hit Enter and it submits the form and doing...
39
by: emre esirik(hacettepe computer science and enginee | last post by:
int n_mines; printf("How many mines do you want in the minefield?"); scanf("%d", &n_mines); while(n_mines>100 || n_mines<0) { printf("Please only enter between 1 and 100"); scanf("%d",...
2
by: berain | last post by:
please can you help me in solute this Assignment i wanna it quickly please Given two ordered arrays A, and B, Write a VB program that reads the contents of the two arrays from file and then...
12
by: Daniel Klein | last post by:
I'm pretty new at php and web stuff so please be gentle with me. I'm trying to get a form to submit when the user presses the Enter key. I do not want to use javascript. I've googled this to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.