View Single Post
Old 03-04-2005, 09:35 PM   #8 (permalink)
letsC
Registered User
 
Join Date: Mar 2005
Posts: 4
letsC is on a distinguished road
Text file input to a Vector

Hi
Thanks for the reply. Here's my attempt to use vectors. It doesn't work. So, there must be something wrong.
Code:
#include <iostream>
#include <fstream>
#include <ios>
using namespace std;
int ip;
float ARR_TIME;
void frag_reassembly (unsigned* a, int, int);
vector<unsigned> a;
    ifstream infile("in.txt");
    infile>>dec>>ARR_TIME;
    infile>>dec>>next;
/* In my opinion, the following should stop reading the file when an empty  line is encountered. NULL = empty line*/
	while (next != NULL) 
	{
               a.push_back(next);
	  infile>>hex>>next;
	}
	cout << " The first data block is: \n";
	for (i =0; i < a.size(); i++)
	{
		cout << a[i] << endl;
	}
         cout<<"[IP Analysis]\n";
/// Analysis of the 2nd Row 4 bytes
      ip=(a[1] & 0xf0000000)>>28;
      cout<<"ip version is "<<dec<<ip<<endl;
This is only part of the code and I haven't included all of it to save space. To give you a better idea, I could email to you separately if you like.
How do I read the second block of data after this? Thanks again for your help!

Last edited by redhead; 03-05-2005 at 07:56 AM. Reason: Use [ code] tags
letsC is offline   Reply With Quote