|
-
September 8th, 2009, 11:30 AM
#1
help with undeclared identifiers
I can't seem to fix this problem, seeing if you guys see anything that I am blindly missing.
I get errors such as:
1>c:\projects\lab2\lab2\word.cpp(64) : error C2065: 'five' : undeclared identifier
1>c:\projects\lab2\lab2\word.cpp(75) : error C2065: 'five' : undeclared identifier
1>c:\projects\lab2\lab2\word.cpp(76) : error C2065: 'twod' : undeclared identifier
and every variable in my string arrays all have the same 'undeclared identifier' error. I am using the 'using namespace std;' so i dont see the problem.
here is a short snippet of my code:
#include <iostream>
#include <iomanip>
#include <string>
#include <stdio>
using namespace std;
int lengths(string* [], string [][]);
int main(){
string* five[5] = {boat, light, gray, mind, soul};
string twod[3][2] = {{cat, dog, hamster},
{bird, monkey, fish}};
int lengths( *five[5], twod[3][2] );
int iei( *five[5], twod[3][2] );
return 0;
}
//Display the length of each string.
int length(string *five[],string twod[][]){
for(int x=0; x<5; x++){
cout << "*five[" << x << "] ";
cout << "has a length of " << five[x].length();
}
}
-
September 8th, 2009, 11:34 AM
#2
Re: help with undeclared identifiers
There's a lot wrong with that code. I'm not entirely sure where to begin.
I guess for starters, I'm not sure why you're making "five" an array of string pointers. Why not just an array of strings? And the initializers should have double-quotes around them.
-
September 8th, 2009, 11:48 AM
#3
Re: help with undeclared identifiers
Well it was on the assignment sheet that "five" had to be a pointer. And thanks, I feel dumb that I didn't realize that one.
-
September 8th, 2009, 11:56 AM
#4
Re: help with undeclared identifiers
There's a difference between a pointer and an array of pointers. Make sure you're absolutely clear on what's being asked of you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|