Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Error I can't figure out

Posted on 1997-12-11
2
Medium Priority
?
185 Views
Last Modified: 2013-12-26
Here is the error I am getting on this bit of code:

Error   : pointer/array required
palindrome.cpp line 35   if(my_str[index_a] != my_str[index_b])


Here is the .cpp stuff:

#include <iostream.h>
#include "boolean.h"
//#include <string.h>
#include "strlib.h"

boolean flip_str(myString my_str);

int main( void )
{
      myString pal;
      
      cout << "Please type in a string: \n";
      cin >> pal;
                   
      if (flip_str(pal) == (TRUE)){
      cout << "The word " << pal << " is a palindrome" << endl;
      }
      else{
            cout << "The word " << pal << " is not a palindrome" << endl;
      }
      
}


boolean flip_str(myString my_str)
{
      int index_a = 0;
      int index_b = my_str.length() - 1;
      
      while (index_a < index_b) {
            if(my_str[index_a] != my_str[index_b])
                  return FALSE;
            index_a++;
            index_b--;
      }
      return TRUE;
}
0
Comment
Question by:charles_kline
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:charles_kline
ID: 1291717
Edited text of question
0
 
LVL 1

Accepted Solution

by:
twall earned 200 total points
ID: 1291718
The error means that the type of the variable you are applying the index or "[]" operator to is not a pointer, an array, or a class for which operator[] is defined.

You don't show the definition of the "myString" class, which is the type of the argument "my_str" in "flip_str".  Is this really the data type/class you want?

If you chagne the type of my_str from myString to a standard String, you'll have an implementation of operator[] which allows the string contents to be indexed.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question