I need help with this please his exercise is designed to give you practice in in
ID: 3833759 • Letter: I
Question
I need help with this please
Explanation / Answer
// Place the 'animals.dat' file in the same folder of this program
#include <iostream>
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
void rectangle(char, int , int);/*prototype */
void line(char,int);
int main()
{
std::ifstream file;
file.open("animals.dat");
while (true) {
char ch;
file >> ch;
if( file.eof() ) break;
else{
int x=1;
int y=ch;
y = y-64; // Since ASCII value of capital 'A' is 65
while(ch != ' '){
rectangle(ch, x, y);
cout << " "; //New line for every single character in animal name
x=x+1;
}
cout << " "; // Severla lines for every animal name
}
}
//system("pause");
file.close();
return 0;
}
void rectangle(char ch, int x, int y){
for(int i=0; i<x; i++){
line(ch,y);
}
}
void line(char ch, int num){
for(int i=0; i<num; i++){
cout << ch ;
}