By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

urgently required source code:::Arrays and pointers to acess strings from a file

P: 1
AOA:
Is there any one to help me.i am in great trouble.i want to
read a file in c++ program that is consisting of data in 2cols and 70 rows.
Tokens freq
abcd 50
dssd 87
. .
. .
. .
. .
i have to store Token(1st col) in one Array1[] and 2nd cols (Freq) in Array2[]
finding the maximun value in array2[].
kindly send me the exact code i want the code urgently.thanxs in advance.
Allah Hafiz...............
Sep 25 '06 #1
Share this Question
Share on Google+
1 Reply


P: 59
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6.         int SIZE = 34; // array size;
  7.         int i = 0;
  8.         string myArray[34];
  9.     ifstream fin("mytext.txt");
  10.         /* Extract all records */
  11.         while (i<SIZE && fin >> myArray[i])
  12.             i++;
  13. return 0;
  14. }
  15.  
I haven't checked the code, but it should work.

I think you can figure out the rest of the problem by yourself.
Sep 25 '06 #2

Post your reply

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