View Single Post
Old 03-03-2005, 04:43 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
I don't see quite the problem. The code below works fine:
Code:
#include <iostream>
#include <fstream>
#include <ios>
using namespace std;

void print_array(unsigned*, unsigned);

int main(int argc, char *argv[])
{
  unsigned x[5]={0};
  unsigned i(0);
  ifstream ifs("in.txt");
  //Let's fill the array from file.
  while( ifs>>hex>>x[i] )
  {
    ++i;
  }
  
  print_array(x, 5);
  
  //Whatever this means :)
  unsigned ip = ( (x[0] & 0xf0000000)>>28);
  cout<<hex<<ip<<endl;
  
  return 0;
}

void print_array(unsigned* arr, unsigned size)
{
  for(unsigned j = 0; j < size; ++j)
  {
    cout<<hex<<arr[j]<<endl;
  }  
}
__________________
Valmont is offline   Reply With Quote