@croco- thanks now there are no errors.
but i have a problem with the output. when i enter a line it just returns the letters of the first word not the complete line?
And is it possible to make a text file and safe text there and call that one instead of typing as input?
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
bool isVowel(char c, int indx)
{
c = tolower(c);
if ((c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u'))
returntrue;
// Don't flag a leading "y" as a vowel, ie "yellow"
if ((c == 'y') && (indx != 0))
returntrue;
returnfalse;
}
int main(int argc, char* argv[])
{
std::string word;
std::vector<std::string> container;
std::ifstream myfile;
myfile.open ("C:\\Users\\CroCo\\Desktop\\data.txt"); // Add the full path of the file
// Check first before go further
if (myfile.fail())
{
std::cerr << "The file could not be opened. " << std::endl;
}
while( !myfile.eof() ) // Read data from the file until hit the end of the file
{
std::getline(myfile, word); // reading line by line
if (word.size() > 3)
{
std::string newword;
for (int i=0; i<word.size(); i++)
{
if (!isVowel(word[i], i))
newword.push_back(word[i]);
}
std::cout << newword << " ";
}
else
std::cout << word << " ";
}
myfile.close(); // Close the file
std::cout << "\n";
std::cin.get();
return 0;
}
@croco- thanks a lot it solved my problem.
I just have one more query is it possible to create a text file which save some words like for tomorrow to 2 mro, fine to f9 and then use these abbreviations in the program using map??
Can someone help me with that.