Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

743 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

13 Experts available now in Live!

Get 1:1 Help Now