error in the for loop

I am attempting to write a program that searches through an array for names
but the loop appears to not even be executing here is the code:

#include "stdafx.h"
#include <iostream>

using namespace std;

int main() {
char* name = new char;
cout << "Enter the name you want to find>";
cin >> name;
char* names[6] = { "keith","brandon","daniel","mom","dad","b" };
int x = 0;
fir (x = 0;x>=sizeof names/names[0];x++) {
if (names[x] == name) {
cout << "We found the name at element " << x <<"!!!\n";
}
else if (x == sizeof names && names[x] != name) {
cout << "We did not not find the name :(\n";
}
else {
cout << "We haven't found the name yet...\n";
}
x++;
}
system("PAUSE");
return 0;

}
When allocating memory for name, you are creating a single char, the loop is for, not fir and sizeof requires parentheses.
I don't think that names/names[0] makes sense
I think that should have been sizeof(names)/sizeof(names[0])
It's pretty stupid, though, since the length of names is known.
Well helios this only a simple program for me to start learning it does nothing
Trust me, you're never going to use that. There's no point in learning it. You're better off forgetting how to determine the size of a static array using sizeof.
Last edited on
Ok thanks
Topic archived. No new replies allowed.