hi there i'm new here i hope you can help me through this homework
i've read like 14 pages of topics about seekg and fstream.. and well.. they didn't solve my problem.
my homework it's about creating a text file from "b to z" without the vocals, then reopen the file for reading/writing with fstream and print on screen the characters in pair position, and also print on screen the entire file in reverse (from z to b) reading with seekg.
i did the code in turbo c++ 3.0 (i know it's quite old but my teacher said we use that one because visual c and the new borland are for lazy people LOL). well i know where's the error maybe is my logic... but i don't know.. the file compiles good.. no error.. but when i run the exe it prints nothing on screen just make several lines of nothing like bunch of '\n' then stops. and hit any key to close it.. pretty weird.
here's the code
#include <iostream.h>
#include <fstream.h>
main()
{
char minu, par,rw;
int cont=0;
ofstream arch("minus.txt"); //create a new .txt
for(minu='b';minu<='z';minu++)
{
if(minu=='e'||minu=='i'||minu=='o'||minu=='u')
{
minu++;
}
arch<<minu;cont++;
} //write form b to z without the vocals
arch.close();
fstream arch2("minus.txt",ios::in|ios::out); //reopen the file for writing/reading
if (arch2.fail())
{
cerr<<"Error al abrir el archivo"<<endl;
} //chek if there's no error opening the file
else
{
for(int t=cont;t>=0;t--)
{
arch2.seekg(t,ios::end);
if(t%2==0)
{
par=arch2.get();
cout<<par;
}
}
// read the file backwards from the last value of cont (must be 21) to 0, cheks if 't' position is pair, if it is must get the character in the pointer position and print it on screen.
for(int t=cont;t>=0;t--)
{
arch2.seekg(t,ios::end);
rw=arch2.get();
cout.put(rw);
}
// read the file backwards again and print each character.
arch2.close();
}
cin.get();
return 0;
}