getting an error I can't figure out....

This is a discussion on getting an error I can't figure out.... within the C++ Programming forums, part of the General Programming Boards category; I was wondering if someone could help I am getting these error message and I can't figure out how to ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    7

    getting an error I can't figure out....

    I was wondering if someone could help I am getting these error message and I can't figure out how to fix them any ideas??

    error C2228: left of '.string' must have class/struct/union type
    C:\Documents and Settings\Owner\My Documents\Computer error C2664: 'lin_search' : cannot convert parameter 1 from 'class index [2000]' to 'class index *[]'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    here is my code
    Code:
    class index{
    	public:
    		int number;
    		char string[100];
    		char url[50];
    };
    
    bool lin_search(index *l[], char word[]){
    	for(int i = 0; i <= 20; i++) 
    		if(l[i].string == word)
    			return true;
    	
    	return false;
    }
    I call the function like this:

    Code:
    	index w[2000];
    	char word[100];
    	int count = 0;
    	ifstream filein("collection.txt", ios::nocreate);
    
    				while(!addrin.eof()){
    					addrin >> word;
    					if(lin_search(w, word) == true){}
    I hope someone can help. Thanks

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Posts
    5,439
    >>bool lin_search(index *l[], char word[]){

    Should be:

    bool lin_search(index l[], char word[]){
    Code:
    int main(void){srand(time(0));for(double l=rand(),l0=0,l00=0;;l0+=0.1){for(double l000=0;l000
    <1;l000+=.001,l+=((double)rand()/RAND_MAX)/0x64,l00+=((sin(l*0x8*atan(l0)*l000-(l0*0x8*atan
    (l)))*0.5)+0.5)){l00-=floor(l00);for(size_t l0000=0,l00000=(size_t)(0x50*(l00));l0000<l00000;++l0000
    )putchar(0x20);putchar(0x61+(int)((double)rand()/RAND_MAX*0x1a));putchar('\n');}}return 0;}

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    7
    I gave that a try but it wasn't passing the class object through the function I couldn't check if the strings were the same.

  4. #4
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    I believe your problem is that l[i] is a pointer, so you need to write your if statement like so:
    Code:
             if(l[i]->string == word)
                 return true;
    At least thats what the error is complaining about.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 3 dimensional figure volume
    By thekautz in forum C++ Programming
    Replies: 2
    Last Post: 01-20-2009, 04:22 PM
  2. trying to figure out someone's code for a plugin
    By paulpars in forum C++ Programming
    Replies: 4
    Last Post: 07-20-2006, 10:57 AM
  3. newb to C, cant figure something out.
    By Phate4219 in forum C Programming
    Replies: 16
    Last Post: 03-06-2006, 12:47 AM
  4. I cant figure out what is wrong with this
    By C++angel in forum C++ Programming
    Replies: 3
    Last Post: 02-20-2006, 09:57 PM
  5. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21