Hello,
I am working on a script that reads each individual character from a txt file and then outputs it depending on whether it's in the alphabet or not.. The problem is, it won't output spaces or anything apart from the string..
e.g.
The text file reads:
Hello, my name is Phorce and this is a test script.
and the output is:
hellomynameisphorceandthisisatestscript
and here is the .cpp file:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
char alphabetU[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
char characters[400];
char inputted[400];
int sizeinputted = sizeof(inputted)/sizeof(inputted[0]);
ifstream file("input.txt");
if(file)
{
char words[447];
for(int i=0; !file.eof(); i++)
{
words[i] = file.get();
for(int o=0; (o < 26); o++)
{
if(words[i] == alphabet[o] || words[i] == alphabetU[o])
{
inputted[i] = alphabet[o];
}
}
}
for(int i=0; (i < sizeinputted); i++)
{
cout << inputted[i];
}
}else{
cout << "Cannot open file";
}
return EXIT_SUCCESS;
}
Anyone have any ideas? Thanks =)