Much better (compared to the other revisions)! But you still haven't fixed
//< MARKER (2) from my previous post!
cin will not simply accept an array of characters. You have got to use the
getline statement for this as well. Replace that with the following instead:
cin.getline(strSearchData, 255, '\n');
// Behold the above [code=cplusplus] tags... its not very hard to use, see ArkM's post above
Also, you store the result of your string compare in a
char .
strcmp returns an
int , so store it one. Otherwise, forget bothering to waste a whole variable to do this, and directly set it as the condition in your if-else construct, so that you'll get something like:
if(strcmp(string1, string2) == 0){ ... }
> still trying to work out how or where in my code i could use bubble sort to search for a particular name in a file
Bubble sort isn't a searching algorithm. As the name implies(strongly), it is an algorithm for
sorting an array's contents. If it is a searching technique that you are looking for, then try the Binary-Search algorithm. For more information on the binary-search algorithm, see
this.
A sample algorithm you could follow to search for a name using B-Search:
1. Load all first names into an array of strings.
2. Apply B-Search algorithm to search for a given name
> how to call a function that uses void
Which function? And what do you mean, "uses void"?