the error is on line 32 of my main program

//interface file

#ifndef STREXTRA_H_INCLUDED
#define STREXTRA_H_INCLUDED
#include <iostream>

using namespace std;

class search
{
    public:
    int find(unsigned char mystring,char letter);
    int find(char mystring[],string word);
    
};

#endif // STREXTRA_H_INCLUDED

//implementation

#include <iostream>
#include <cstdlib>

using namespace std;
#include "strextra.h"

int search::find(unsigned char mystring,char letter)
{
    return=strcspm(mystring,letter);
}

//main program

#include <iostream>
#include <cstdlib>
using namespace std;
#include "strextra.h"


int main()
{
    cout<<"enter max number of characters in the sentence";
    int number;
    cin>>number;
    cout<<"enter a sentence";
    char let;
    char mycstring[number];
    for(int i=0; i<number; i++)
    {
        cin>>let;
        mycstring[i]=let;
    }
     mycstring[number]='\0';
     cout<<"my string is\n"<<mycstring<<"\n";
    cout<<"enter the character you are trying to find in the string above\n";
    char alpha;
    
    char lett[1];
    for(int a=0; a<1; a++)
    {
        cin>>alpha;
        lett[a]=alpha;
    }
    lett[1]='\0';
    find(unsigned mycstring, lett);
    
}

Recommended Answers

All 3 Replies

because find was never defined it was defined inside a class you gotta make an object from that class and call it from the object.

AKA

search s;
s.find(unsigned mycstring, lett);

thanks i completely forgot about that.

also, there should be no "=" in this line:

return strcspm(mystring,letter);

also, did you mean for "strcspm" to be "strcpn" ? If so , that lives in cstdio

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.