arg...ok now it dies in the middle of doing work after making these changes.
Code:
// Program to perform file processing using the FILE structure
// Author: Jules Larson. Revised by Jeremy Jones 2005
#include <iostream>
using namespace std;
int main()
{
char Make[20], Model[20];
unsigned int CarYear;
long Mileage;
FILE *CarInventory = fopen("cars.inv", "w");
if (CarInventory == NULL ) {
// do something else
} else {
// read the file
}
cout << "Enter the following pieces of information\n";
cout << "Make: "; gets(Make);
cout << "Model: "; gets(Model);
cout << "Year: "; cin >> CarYear;
cout << "Mileage: "; cin >> Mileage;
fprintf(CarInventory, "%s\n", Make);
fprintf(CarInventory, "%s\n", Model);
fprintf(CarInventory, "%s\n", CarYear);
fprintf(CarInventory, "%s\n", Mileage);
CarInventory = fopen("cars.inv", "r+");
fscanf(CarInventory, "%s\n", Make);
fscanf(CarInventory, "%s\n", Model);
fscanf(CarInventory, "%d\n", &CarYear);
fscanf(CarInventory, "%d\n", &Mileage);
cout << "Information about the car";
cout << "\nMake: " << Make;
cout << "\nModel: " << Model;
cout << "\nYear: " << CarYear;
cout << "\nMileage: " << Mileage;
fclose(CarInventory);
CarInventory = fopen("cars.inv", "r+");
return 0;
}
hmm maybe I am just not seeing something or to new to C\C++ sorry for the anoyence. Just dont know why I am getting the "Windows needs to close this program" error...mar..Thanks for the help anyways.