Lab11 - Thomas Nanke CIS 200-001 CIS 200L-001 Lab #11...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Thomas Nanke CIS 200-001 CIS 200L-001 Lab #11 Binary Files 4/14/08
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Machine type that I used is the PC with Microsoft XP Professional as the operating system. The compiler type is the Microsoft Visual 6.0 Compiler. The goal of this lab was to write an integer array and a float array of 1 through 100 into two separate files. Then from these files, we were to read every 10 th number and print it to the screen. File input/output is different from regular text files when you’re dealing with binary files. It is also much more efficient. Here is a copy of my source code #include<iostream> #include<fstream> using namespace std; char *memblock; fstream::pos_type size; fstream::pos_type size2; void main() { //Question 1 int* ptr1; int x[100]; for(int i=0; i<100; i++) //initializes the values of each element in the array { x[i]=i; if((i+1)%10==0) cout<<x[i]<<endl; //prints every 10th element } ptr1=&x[0]; //memory address of the start of the x array fstream file("integer.dat",ios::out|ios::binary|ios::ate);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/25/2010 for the course CECS CIS 200 taught by Professor Jieshen during the Winter '08 term at University of Michigan-Dearborn.

Page1 / 4

Lab11 - Thomas Nanke CIS 200-001 CIS 200L-001 Lab #11...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online