943,793 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 968
  • C RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 27th, 2009
0

HELP..!!

Expand Post »
hey..i am a novice when it comes to C programming coz i am a bio-engineer..however, i landed a job with an It giant, and we have been allotted a project(for practice's sake though!) by them on a trainee level..ofcourse, it involves a normal-login program..i was able to figure out most of the code however i got stuck with teh bit of displaying a "*" instead of the the actual passwords(typical of most login sites)..

could someone please help me out with this..
il still produce the rest of the code which requires us to make a character sensitive comparison in case of teh password..please feel free to correct me but do offer explanations..

thanx in advance

code-->

void
fnlogincheck();
main(int argc,char**argv)
{
system("cls");
fnlogincheck();
return 0;
}
void
fnlogincheck();
{
char *pcloginid[3]={"user1","user2","user3"};
char *pcpwd[3]={"Potato","Tomato","Turnip"};
int l,p,i,c;
char login[5];
char password[6];
printf("\n\n\n\n\t\tEmployee Information System\n");
printf("\t\t===========================\n\n");
printf("\t\tLogin Screen\n");
printf("\t\t============\n");
printf("\n\t\tEnter User Id\t: ");
scanf("%c",&login);
printf("\n\t\tEnter Password\t: ");
scanf("%c",&password);


{
l=strcmp(&loginid[i], login);
p=!strcmp(&pwd[i],password);
for(i=o,i<=3,i++)
}
{
password[c]= password[6]
printf("*");
for(c=0,c<=6,c++)
}
{
if l=0,p=0
printf("LOGIN ACCEPTED");
else printf("LOGIN DENIED");

exit
}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
orthographer is offline Offline
14 posts
since Jan 2009
Jan 27th, 2009
0

Re: HELP..!!

You gotta use code tags for people to consider answering to your post.
Here's the syntax:

[code=c]
.
.
your code here
.
.
[/code]
Anyway, just a cursory glance through your code showed a few big mistakes:

1. Use int main()
2. You are using %c to get a string- should be %s.
3. Arrays are always passed to functions using pointers (acts as call by reference- sort of).
Last edited by devnar; Jan 27th, 2009 at 4:28 am. Reason: Added more info
Reputation Points: 124
Solved Threads: 18
Junior Poster
devnar is offline Offline
148 posts
since Sep 2008
Jan 27th, 2009
0

Re: HELP..!!

  1. .
  2. .
  3. void
  4. fnlogincheck();
  5. main(int argc,char**argv)
  6. {
  7. system("cls");
  8. fnlogincheck();
  9. return 0;
  10. }
  11. void
  12. fnlogincheck();
  13. {
  14. char *pcloginid[3]={"user1","user2","user3"};
  15. char *pcpwd[3]={"Potato","Tomato","Turnip"};
  16. int l,p,i,c;
  17. char login[5];
  18. char password[6];
  19. printf("\n\n\n\n\t\tEmployee Information System\n");
  20. printf("\t\t===========================\n\n");
  21. printf("\t\tLogin Screen\n");
  22. printf("\t\t============\n");
  23. printf("\n\t\tEnter User Id\t: ");
  24. scanf("%c",&login);
  25. printf("\n\t\tEnter Password\t: ");
  26. scanf("%c",&password);
  27.  
  28.  
  29. {
  30. l=strcmp(&loginid[i], login);
  31. p=!strcmp(&pwd[i],password);
  32. for(i=o,i<=3,i++)
  33. }
  34. {
  35. password[c]= password[6]
  36. printf("*");
  37. for(c=0,c<=6,c++)
  38. }
  39. {
  40. if l=0,p=0
  41. printf("LOGIN ACCEPTED");
  42. else printf("LOGIN DENIED");
  43.  
  44. exit
  45. }
  46.  
  47.  
  48. heres the code...and the explanation as to what is wrong, is in the original post( very1st post)..
  49.  
  50. thnx..
  51. .
  52. .
Reputation Points: 10
Solved Threads: 0
Newbie Poster
orthographer is offline Offline
14 posts
since Jan 2009
Jan 27th, 2009
0

Re: HELP..!!

great...such an active discussion community and yet no-one to help an aspiring programmer!
nevermind..

I shall figure something out myself..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
orthographer is offline Offline
14 posts
since Jan 2009
Jan 27th, 2009
0

Re: HELP..!!

I gave you 3 points on which to work on. You didn't bother to make any corrections in your next post or even ask questions about what I had suggested. There are a lot of other fundamental syntax mistakes too like:
The incorrect if statement syntax,
Redundant braces,
Missing semi-colons,
Illegal use of comma operator,
Use of assignment instead of comparison operator etc.
I would suggest having a look at the 'Starting C' thread.
Reputation Points: 124
Solved Threads: 18
Junior Poster
devnar is offline Offline
148 posts
since Sep 2008
Jan 27th, 2009
0

Re: HELP..!!

* You also didn't bother to read the rules as requested multiple times during registration (code tags and the title show that)
* you didn't format you code so people can read it
* you somehow think people are here just to bail you out of your problem and don't have lives outside of this forum
* and as devnar implied, you don't know the basic syntax of C and expect us to teach you the language. That's not why people volunteer on this board.
Last edited by WaltP; Jan 28th, 2009 at 10:58 pm. Reason: wrong name -- sorry devnar
Moderator
Reputation Points: 3278
Solved Threads: 892
Posting Sage
WaltP is online now Online
7,718 posts
since May 2006
Jan 28th, 2009
0

Re: HELP..!!

Well...true, I dont know the basic syntax since it has already been articulated by me that I am a novice..and Devnar, I did make amendments like you asked me to, but for some reason my compiling wont proceed beyond the third brace( and thats the only error shown by my compiler).

would it make sense for me to correct my program at three places and again produce it here when there's a plethora of mistakes in it? And mind you, my compiler does not show these as errors.

@ waltp- I am not here to ask you guys to solve my problems but to discuss and learn what the problems might be..I am not lackadaisical by any mean and I do have every ounce of grey and white matter working toward understanding this new concept which perhaps is not easy for me since I come from a Bio background.

Everyone's not adept at programming and neither is anyone born with such skills! Owing to the life I have beyond this forum, there is a dearth of time and hence, I would ask you to excuse my formatting ignorance. I shall read the formatting rules and then get back.

@ DEVNAR---> il go through the 'starting C' thread as you suggested. thank you for considering my problem though, il re-produce the code after making the changes along with the compiling errors.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
orthographer is offline Offline
14 posts
since Jan 2009
Jan 28th, 2009
0

Re: HELP..!!

My suggestion:

Take a C course in some center in your city. WILL help you out...
Reputation Points: 49
Solved Threads: 1
Posting Whiz
riahc3 is offline Offline
302 posts
since May 2008
Jan 28th, 2009
0

Re: HELP..!!

Click to Expand / Collapse  Quote originally posted by riahc3 ...
My suggestion:

Take a C course in some center in your city. WILL help you out...

hey..thanx a lot for the sugestion, but i'm afraid, time is not on my side..I would be leaving in a month, and the company i will be joining already has 6 months alotted as a training period..

pus, there are a lot of other things to cater to at the moment. This was just a project given by them to us on a practice basis.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
orthographer is offline Offline
14 posts
since Jan 2009
Jan 28th, 2009
0

Re: HELP..!!

>>Take a C course in some center in your city. WILL help you out...
I think a C course is a waste of time(even when you've got some to spare). I've learned more from the Internet and Daniweb than I have from my course.
Reputation Points: 124
Solved Threads: 18
Junior Poster
devnar is offline Offline
148 posts
since Sep 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Image rotation
Next Thread in C Forum Timeline: If else statement





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC