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?

Recommended Answers

All 2 Replies

Member Avatar for jencas
found = (*point).find("test");
found = (*point).find("test");

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.