I m working how to make a program to find word in a string. for this i posted my code it has logical error can any tell me what to do next?? i m tokenizing string after that what to do? thanks in advance..
#include <iostream>
#include <cstring>
using namespace std;
void main()
{
char string[100], keyword[100], *string_ptr = string, *keyword_ptr=keyword;
cout << "Enter sentence\n";
cin.getline(string_ptr,100,'\n');
cout << "Enter search word\n";
cin.getline(keyword_ptr,100,'\n');
string_ptr = strtok(string, " ");
while (string_ptr != NULL)
{
//cout << string_ptr <<endl;
string_ptr = strtok(NULL , " ");
}
keyword_ptr = strtok(keyword, " ");
while (keyword_ptr != NULL)
{
//cout << keyword_ptr << endl;
keyword_ptr = strtok(NULL , " ");
}
}