Hello. I would like If possible get some input and assisstance on operations with external files.
So this is what i have so far:
#include <iostream>
#include <fstream>
using namespace std;
void main (){
cout<<" Input into the file '.' " <<endl;
char zbor[20];
ofstream dat;
dat.open("tekst.txt");
do{
cin.getline(zbor,20);
if(strcmp(zbor,".")){
dat<<zbor<<endl;
}
}
while(strcmp(zbor,"."));
dat.close()
}
Tnis so far opens a .txt file named tekst. And asks the user to input strings maximum of 20 characters. The loop goes on until the user iputs '.' . What i need now is 2 things:
1. Now I open the file with say ifstream dat1. I read the sentences the user inputs right? How do I check the number of times a letter from the alphabet apears in the file?? And then I need to print out letter:numberoftimesappeard in the whole file tekst.
2. Second Thing i need is to change a word in the file with another word. That is replace one word with another.... In this case the user wont get to input whole sentences wth cin.getline only input words with only cin....
Im quite familiar with opening to write to and read from files . I am at universyti and Im preparing an exam for friday witch is sure to have I/O from files.. And I kinda missed the class where they lectured about this... Can i get some help with the functions?? Like put and get... Any ideas?? Can anyone post an example.. I would be really gratefull..... Thanks