Hello, i'm writing a program which can read a text file (input) and it can find keywords such as "Module" and "Form" from the input text file. The keywords found are then write into an output file. My program should search for those keywords and return the line of code where the keywords are found.
The following is my program but there are errors >> no conversion from 'int' to 'char *'. Can anyone help me to check on my coding?
Besides, can someone teach me how to return the line of code when the keyword is found?
Thank you very much for your help. I have attached the input file.
cpp
#include "stdafx.h"
#include <iostream>
#include <fstream>
const int COL_LEN=500;
const int ROW_LEN=500;
typedef char Content[COL_LEN];
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
Content word[ROW_LEN];
int n=0;
ifstream infile("Project1.txt");
ofstream outfile("output_Project1.txt");
while(infile.getline(word[n++], COL_LEN) && n<ROW_LEN);
--n;
for (int i=0;i<n;i++){
if(word[i]=='M'&&word[i+1]=='o'&&word[i+2]=='d'&&word[i+3]=='u'&&word[i+4]=='l'&&word[i+5]=='e')
outfile <<word[i] <<endl;
}
return 0;
}
Project1.txt ( 2.03k )
Number of downloads: 3Mod edit: You only need to post the download link once!