| | |
Search string?
![]() |
•
•
Join Date: Dec 2006
Posts: 6
Reputation:
Solved Threads: 0
I am trying to do a sequential string, but when I run my program I recieve three errors:the first one talks about 'searchList' : cannot convert parameter 3 from 'const char [4]' to 'std::string []
( I tried putting code tags by inserting my code between the , but I am not positive if it is displaying) Sorry for any convenience!
( I tried putting code tags by inserting my code between the , but I am not positive if it is displaying) Sorry for any convenience!
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <fstream> using namespace std; int searchList(string array[], int, string value[]); const int ARRAY_SIZE = 3; int main() { string someArray[ARRAY_SIZE] = {"mouse", "cat", "ant"}; int results; results = searchList(someArray, ARRAY_SIZE, "ant"); if (results == -1) cout << "You did not earn 100 points on any test\n"; else { cout << "You earned 100 points on test "; cout << (results + 1) << endl; } return 0; } int searchList(string array[], int numElems, string value[]) { int index = 0; // Used as a subscript to search array int position = -1; // To record position of search value bool found = false; // Flag to indicate if the value was found cout << "made it here" << endl; while (index < numElems && !found) { if (array[index] == value[]) // If the value is found { found = true; // Set the flag position = index; // Record the value's subscript } index++; // Go to the next element } return position; // Return the position, or -1 }
Last edited by hellokitty88; Mar 16th, 2008 at 5:42 am. Reason: code tags
![]() |
Similar Threads
- Search A String for proper format (C++)
- Search A String (C++)
- search in a string (Assembly)
- Search for a string in a variable--- (PHP)
- How to search for a string in a file (C#)
- Search string in a text file (C)
- Search a string of ',' (C++)
- New User (C)
- "String class" (Java)
- Return Length of a string? (C++)
Other Threads in the C++ Forum
- Previous Thread: read text file into a structure
- Next Thread: C++
| Thread Tools | Search this Thread |
action api array auto based beginner binary bitmap c++ c/c++ calculator challenge char class classes code coding compile console conversion count createcopyofanyfileinc delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game garbage givemetehcodez graph gui hmenu homeworkhelp homeworkhelper iamthwee ifstream input insert int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node noob output parameter pointer primenumbersinrange problem program programming project python random read recursion reference rpg sockets string strings temperature template test text text-file tree url variable vector video win32 windows winsock wordfrequency wxwidgets






