You should be passing a pointer to the first character of the string.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Look, you're the one posting your code and saying "fix it". It's really getting to be past time for you to try to do some work rather than using this site as a "fix my homework" type of thing. I'm guessing there is a language barrier here, otherwise I wouldn't have been so lenient thus far.
Make an attempt to do this by yourself -- we'll show you any necessary corrections. If you don't understand what a pointer is, then don't try to write your own strcmp. And perhaps you should do some reading or re-reading of some reference section on pointers.
int strcomp(char pass)
Here, pass is not a pointer.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
You seem to be ignoring things such as "never use gets" and such things, which seems to indicate that you don't really want to learn, you just want someone else to make your assignments correct.
Your posts dump code, and say, "plz debug". Do you post compiler errors/warnings and ask for explanations? [edit]Once[/edit] Do you explain what attempts you have made in solving the problem yourself? Do you demonstrate that you are learning by acknoweldging it in your threads explicitly, or implicitly by using such advice in other threads? To most of these, I'd say what I have seen is generally "no".
[edit]Have you once had the courtesy to post code within [code][/code] tags?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
lol, on my linux distribution man gets says something in the lines of DO NOT USE THIS FUNCTION IT IS NOT SAFE... and no, many of the uses of scanf is unsafe (k, Im not an expert but atleast the string inputs are bad)... cin >> should be good aslong as proper objects are used, a while since I used it but I suppose cin >> (char * type) would be unsafe if used, getline( cin, (string type) linebuf) on the other hand is (safer I suppose you could still missuse it somehow).
perniciosus
Junior Poster in Training
78 posts since Nov 2005
Reputation Points: 29
Solved Threads: 4
As I said, scanf("%s", cstring) is no better than gets(cstring), as well as cin >> cstring (I dont feel like checking if that is actually availible though)... cin >> (int type, or any other type that can safly handle the data that can come out of it) is however safe, as well as scanf("%d", &int_type)....
perniciosus
Junior Poster in Training
78 posts since Nov 2005
Reputation Points: 29
Solved Threads: 4
Well there are proper uses to cin and scanf, it is only the get string part that is inherently bad... while on the other hand gets has no safe use whatsoever.
(Well I suppose one should include a warning for those uses as well, I am not sure it is not done I only remember seeing that in the man page of gets)
perniciosus
Junior Poster in Training
78 posts since Nov 2005
Reputation Points: 29
Solved Threads: 4