Solved

Its Me again.  How can I branch to a function to compare strings?

Posted on 2002-04-26
5
192 Views
Last Modified: 2010-04-02
I'll be broke before I understand this C++. Haha.

I want to branch to a function to compare strings, however;  the parameters confuse me , and I get errors like c2664 " Function cannot convert parameter number from type 1 to type 2".

Here's the relevant code: ( I think).
{
// other code

int curse(char, char);
...

     int ctr=0;
loop: ctr++;
            if (ctr>10)
                 goto dead;

            cout << "\n" << qstring;
            cin.get(what,256);
            char swore=curse(char w,char s);
       if (0==stricmp(what,testone))
          goto next;
       cin.ignore(256,'\n');
        goto loop;

// other code
Return 0
}


curse(char s1, char s2)
{
     strcpy(s2," why you");
     if (0==stricmp(s1,s2)
          cout << " why you too!!/n" << "Just answer the question\n";
     return 0;
}

Hope this is clear enough.  Any other questions- let me know.

Thx
Rick

0
Comment
Question by:rixxagain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Accepted Solution

by:
GGRUNDY earned 100 total points
ID: 6972788
I must confess that I haven't quite understood what you are trying to acheive but have a look at this and see if it makes any sense to you.

  char zTestone[]="some stuff";
  char zWhat[256];
  bool curse(char* );
  for(int i=0; i<10; i++){
     cout << "\n?";
     cin.get(zWhat,256);
     if(!curse(zWhat) && (0==_stricmp(zWhat,zTestone)))continue;
     cin.ignore(256,'\n');
    }

     return 0;
  }

bool curse(char* s)
{
  if (stricmp(s," why you")==0){
    cout << " why you too!!/nJust answer the question\n";
    return true;
    }
  return false;
  }

cheers
0
 
LVL 22

Expert Comment

by:Adam Leinss
ID: 6972882
It may help to post all of the code at a URL, then give us the complete error messages with line numbers. For example, like this: http://vhosts.stealth.kirenet.com/~aleinss/multithread.c
I have asked questions on here myself before and it helps lot.

Sounds like you are trying convert one incompatible variable type to another type.

In terms of your code...I have no clue what you are doing.  For starters, using goto is extremely bad programming taste [the assembly people can stay away from this question ;)], even if you are playing with C/C++. And then you have stuff like this:

char swore=curse(char w,char s);

when curse returns an int, not a char (although it probably will work, since char really is just an ASCII integer value internally).
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7036266
Please update and finalize this old, open question. Please:

1) Award points ... if you need Moderator assistance to split points, comment here with details please or advise us in Community Support with a zero point question and this question link.
2) Ask us to delete it if it has no value to you or others
3) Ask for a refund so that we can move it to our PAQ at zero points if it did not help you but may help others.

EXPERT INPUT WITH CLOSING RECOMMENDATIONS IS APPRECIATED IF ASKER DOES NOT RESPOND.

Thanks,

** Mindphaser - Community Support Moderator **

P.S.  Click your Member Profile, choose View Question History to go through all your open and locked questions to update them.
0
 
LVL 11

Expert Comment

by:griessh
ID: 7122177
Dear rixxagain

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "GGRUNDY"

comment(s) as an answer.

If you think your question was not answered at all, you can explain here why you want to do this and post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/


PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7138096
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question