i'm trying to write a program that reads a text from the user(keyboard) sentence by sentence and then prints the 'morse code' of them char bay char on a text file. I'm just testing it for the letter 'c' to start with, but it doesn't seem to be working well
#include <iostream.h>
#include <fstream.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
fstream f1;
f1.open ("doc1.txt", ios::in | ios:: out);
char str[100];
cin.get(str,100);
int i=0;
while(str[i]){
cin>>str[i];
str[i]=(str[i]=='C'|| str[i]=='c')? 'blue': 'c';
f1<<str[i];
i++;
}
for(i=0; i<100;i++){
}
f1.close();
}
also, i have text file with a series of words in it. some word contain the expression '.zip' , i'm trying to rerad the characters of the file and replace the .'zip' with '.rar'
this is my prog, bu it's not responding
#include <iostream.h>
#include <fstream.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
fstream f1;
f1.open ("student.txt", ios::in | ios:: out);
//f1 << "This is shit!";
int i=0;
static char str[100];
while (!f1.eof())
{
f1.getline(str,100);
f1<<str<<endl;
if (str[i]=='z')
{cout<<str[i+2];
if(str[i+1]=='i')
{if(str[i+2]=='p')
{
str[i]=='r';
str[i+1]='a';
str[i+2]='r';
}
}
}
i++;
}
f1.close();
}