#include <iostream> #include <string> using namespace std; void main() { int status[26]; string kod[27]; [color="#33CC00"]// this is the element that i need to store in .text file and retrieve using ifstream... i fail to use the ifstream fuction hence cant retrieve the all the kod[27] data to be use from .text file[/color] string alpha[27]; string human[100]; string temp; char ans; int i,jump,cool,ulang,hold; for(int A=0;A<26;A++) { alpha[A]="A"; A++; } alpha[26]=' '; [color="#33CC00"]kod[0]=".-"; kod[1]="-..."; kod[2]="-.-/>."; kod[3]="-.."; kod[4]="."; kod[5]="..-"; kod[6]="----"; kod[7]="...."; kod[8]=".."; kod[9]=".----"; kod[10]="-.-/>"; kod[11]=".-.."; kod[12]="--"; kod[13]="-."; kod[14]="---"; kod[15]=".--."; kod[16]="--.-/>"; kod[17]=".-."; kod[18]="..."; kod[19]="-"; kod[20]="..-"; kod[21]="...-"; kod[22]=".--"; kod[23]="-..-"; kod[24]="-.-/>-"; kod[25]="--.."; kod[26]="~";[/color][size=6] do { for(int yo=0;yo<26;yo++) { status[yo]=0; } ulang=0; cool=0; system("cls"); cout<<"\n\t<Symbol '/' to stop >"; cout<<"\n\n\t Insert the code Morse :\t"; for(i=0;i<100;i++) { cin>>temp; if(temp=="/") { break; } else { human[i]=temp; } } cout<<"\n\tHasil :\t"; for(int j=0;j<i;j++) { jump=0; for(int t=0;t<27;t++) { if(human[j]==kod[t]) { cout<<alpha[t]<<' '; jump++; if(human[j]!="~") { status[t]++; cool++; } } } if(jump==0) { cout<<"? "; } } cout<<"\n\n\t number of alphabet had been used : "<<cool<<" alphabet"; cout<<"\n\n\tnumber of repeated alphabet :-\n"; hold=0; for(int fke=0;fke<26;fke++) { if(status[fke]>1) { hold++; cout<<"\n\t\t Alphabet "<<alpha[fke]<<", repeated "<<status[fke]<<" times.."; } } cout<<"\n\n\t Number of repeated alphabet : "<<hold<<" alphabet"; cout<<"\n\n\tContinue ? (y/n)\t"; cin>>ans; }while(ans=='y'||ans=='Y'); cout<<"\n\n"; }
*** MOD EDIT: Added code tags. Please

This post has been edited by JackOfAllTrades: 02 November 2009 - 08:36 AM