I am trying to read in from an input file and everytime the word "is" appears in the file, replace it with "are".
will this work?
for (int i=0, i<kiSize, i++)
You're reading it in, but you're not writing it back to the file. What you're gonna have to do is either write it to another file, or keep all of the words in a buffer and overwrite the original file.
You should also use ifIn>>word; so it breaks at the spaces.
You should get some errors from that line. getline() returns a reference to the istream object, and it's parameters are char* and long.
istream& getline(char* pArray, streamsize n)
And, what the heck is:
?? Some undeclared, anonymous, dimensionless place holder? This is the way getline works:
There is a version for string types too:
Even if your "word=ifIn.getline()" statement did work, word is going to equal a whole line of data, so it's not going to equal "is".
i figured out the getline thanks for the help.
but now i have to read in a word and insert the word "uh" after the 4th letter in that word.
read in "programmer" and change it to "prog-uh-rammer"
how would i do that?
to leave programmer intact use a different buffer to hold proguhrammer. use a loop to read in first four char of word to change. Then add uh to new word. Then read last part of old word into new word. Works best if you use two different index variables, one for the old word and one for the new word, increasing the index variables appropriately.