Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How to find word in a string

$
0
0
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 , " ");
	}


	
}



Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>