1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int
main ()
{
int a, MAX = 50, b, numberLines;
char word1[10] = " " , word2[10] = " ", word3[10] = " ";
char message1[50], message2[50], message3[50];
char * word;
fstream wordsin("wordsin.txt", ios::in);
fstream wordsout("wordsout.txt", ios::out | ios::trunc);
if (!wordsin || !wordsout)
{
cout << "Error: Unable to open input or output files";
cin.get();
exit(1);
}
wordsout << "Enter the first words " ;
wordsin >> setw(11) >> word1;
wordsout << "Enter the second words " ;
wordsin >> setw(11) >> word2;
wordsout << "Enter the third words " ;
wordsin >> setw(11) >> word3;
wordsout << "Enter the first message " ;
wordsin.getline(message1, 50, ' ');
wordsout << "Enter the second message " ;
wordsin.getline(message2, 50);
wordsout << "Enter the third message " ;
wordsin.getline(message3, 50);
wordsout << message1 << message2 << message3;
word = strstr(message1, word1);
wordsout << word;
for (a = 0; a < MAX; a++)
{
for (b = 0; b <numberLines; b++)
{
// if (strstr(message1[a], word1[a] ) )
wordsout << b;
}
}
wordsin.ignore ();
wordsin.get ();
return 0;
}
| |