error in 'strcmp'

Copied this code from text book on Beginner C++:
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int i;
char str(80);

char numbers[10][80] = {
"Tom", "555-3322",
"Mary", "555-8976"
"Jon", "555-1037", //10
"Rachael", "555-1400",
"Sherry", "555-8873"
};
cout << "Enter name: ";
cin >> str;
for(i=0; i < 10; i += 2)
if(!strcmp(str, numbers[i])) {
cout << "Number is " << numbers[i+1]<< "\n";
break;
}
if(i == 10) cout << "Not found. \n";

return 0;
}
and got this error msg: c:\documents and settings\paul\my documents\visual studio 2010\projects\ch04p22\ch04p22\ch04p22.cpp(18): error C2664: 'strcmp' : cannot convert parameter 1 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Would "char* ptr str; and if(!strcmp(&str, numbers[i]))
solve the problem?
Is it char str(80) or char str[80]?

...and use code tags (sigh)
Duh!!!!

& code tags are before and after code in our questions?

Thanks. I looked at the code a bunch of times and missed the d... brackets. Also missed the missing commas in the data! Sign of age!

I have been using a program called 'Clipomatic' written by Mike Lin in C++. I've been using it since Win 95, now on XP. Clipomatic is a clipboard-caching program that remembers text that you have copied to the clipboard, even after it has been replaced by other text. Really useful, especially in coding. You can cut several items and move them 1 at a time to different lines. Find it with a search.


Topic archived. No new replies allowed.