0

Hey,

What i'm trying to do is to use the string.find command with a pointer.
Here is the code that i've written sofar.

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string one[3];
	string two[3];
	string searchalt;	
	string *point;
	int search[3];
	int a = 0;
	size_t found;
	cin >> searchalt;	
	if (searchalt == "1")
	*point = one[a];
	if (searchalt == "2")
	*point = two[a];	
	
	while (a <= 2)
	{
		found = *point.find("test"); //Here is the error
		if (found != string::npos) 
		{
			search[a] = 1;
			a++;
		}
		else
		{
			a++;
		}
	}
}

The error says: untitled.cpp:21: error: request for member ‘find’ in ‘point’, which is of non-class type ‘std::string*’

Does anyone know how to fix it?

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by kbshibukumar
0
found = (*point).find("test");

Exactly........
Have a better practice to initialize Point at the time of declaration.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.