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
Solved

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
thread-safe code in c++ 2 115
Using Diagnostic tools in VS2015: Unresoved allocations 19 102
Problem with SqlConnection 4 177
Safe conversion? 4 72
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

790 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