ifstream matrix 15x15
Feb 11, 2010 at 8:59pm UTC
i'm trying to get my program to say Enter to continue every 15x15 matrix. i get the program to stop and it reads the numbers from the text file, but it just goes straight down to the complete after reading the numbers off. any help is appreciated :)
~~~~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
int main(){
clrscr();
ifstream in1("nums.dat" );
int ct=0;
int *p=new int [1300];
int forever=1;
cout << "\n\n\t Lab-21" ;
cout << "\n" ;
while (forever){
in1 >> *(p+ct);
if (*(p+ct) == -1) break ;
ct++;
} // WHILE LOOP
for (int i=0; i<ct; i++){
cout << "\t" << *(p+i);
if ((ct)%15==0) cout << "\n" ;
if ((ct)%150==0){
cout << "\n\n\tEnter to continue." ;
getch();
} // if
} // FOR LOOP
cout << "\n\n\tTotal data = " << ct;
delete p;
in1.close();
cout << "\n\tComplete" ;
return 0;
} //MAIN
Topic archived. No new replies allowed.