Solved

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

Posted on 2002-04-26
5
186 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now