943,685 Members | Top Members by Rank

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

Compiling errors with braces!

Expand Post »
As some of you would already know, I made a program which accepts login and password from users and shows "*" instead of actual password characters.
I know the program is grossly incorrect but I still tried to apply whatever I picked up using books and example programs.

*****DISCLAIMER- I am not an IT wizkid and calling me a beginner would be an extrapolated statement aswell. I am here to learn and discuss and not to be admonished at***************


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

Re: Compiling errors with braces!

compiling errors->


compiling...
practice1.c
- c:\program files\microsoft visual studio\myprojects\practice\practice1.c(11) : error C2449: found '{' at file scope (missing function header?)
- c:\program files\microsoft visual studio\myprojects\practice\practice1.c(15) : error C2059: syntax error : '}'
- c:\program files\microsoft visual studio\myprojects\practice\practice1.c(18) : error C2449: found '{' at file scope (missing function header?)
- c:\program files\microsoft visual studio\myprojects\practice\practice1.c(32) : error C2059: syntax error : '}'
- c:\program files\microsoft visual studio\myprojects\practice\practice1.c(39) : error C2449: found '{' at file scope (missing function header?)
- c:\program files\microsoft visual studio\myprojects\practice\practice1.c(43) : error C2059: syntax error : '}'
Error executing cl.exe.

practice1.obj - 6 error(s), 0 warning(s)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
orthographer is offline Offline
14 posts
since Jan 2009
Jan 28th, 2009
0

Re: Compiling errors with braces!

WOW....

I have no idea what you are trying to do but you are WAY over your head.
1: Learn to use "tab"
2: password[c]= password[6] with no ; at the end? (Thatll problably solve 99% of the complying errors
3:
What the **** is this:
  1. {
  2. l=strcmp(&loginid[i], login);
  3. p=!strcmp(&pwd[i],password);
  4. for(i=o,i<=3,i++)
  5. }
  6.  
  7. {


Personally I think you come from another programming language that should either stick to it or reread from C manuals.
Reputation Points: 49
Solved Threads: 1
Posting Whiz in Training
riahc3 is offline Offline
298 posts
since May 2008
Jan 28th, 2009
0

Re: Compiling errors with braces!

This complys:

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4. #include<ctype.h>
  5. #include<math.h>
  6.  
  7. void fnlogincheck();
  8. int main(int argc,char**argv)
  9. {
  10. system("cls");
  11. fnlogincheck();
  12. return 0;
  13. }
  14.  
  15. void fnlogincheck()
  16. {
  17. char *pcloginid[3]={"user1","user2","user3"};
  18. char *pcpwd[3]={"Potato","Tomato","Turnip"};
  19. int l,p,i,c;
  20. char login[5];
  21. char password[6];
  22. printf("\n\n\n\n\t\tEmployee Information System\n");
  23. printf("\t\t===========================\n\n");
  24. printf("\t\tLogin Screen\n");
  25. printf("\t\t============\n");
  26. printf("\n\t\tEnter User Id\t: ");
  27. scanf("%s",&login);
  28. printf("\n\t\tEnter Password\t: ");
  29. scanf("%s",&password);
  30.  
  31.  
  32.  
  33. //l=strcmp(&loginid[i], login);
  34. //p=!strcmp(&pwd[i],password);
  35.  
  36. password[c]= password[6];
  37. printf("*");
  38. for(c=0;c<=6;c++)
  39.  
  40. {
  41. if( l=p)
  42. printf("LOGIN ACCEPTED");
  43. else
  44. printf("LOGIN DENIED");
  45.  
  46. exit;
  47. }
  48. }

But again, What the **** are you trying to do with this code???
Reputation Points: 49
Solved Threads: 1
Posting Whiz in Training
riahc3 is offline Offline
298 posts
since May 2008
Jan 28th, 2009
0

Re: Compiling errors with braces!

Click to Expand / Collapse  Quote originally posted by riahc3 ...
This complys:

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4. #include<ctype.h>
  5. #include<math.h>
  6.  
  7. void fnlogincheck();
  8. int main(int argc,char**argv)
  9. {
  10. system("cls");
  11. fnlogincheck();
  12. return 0;
  13. }
  14.  
  15. void fnlogincheck()
  16. {
  17. char *pcloginid[3]={"user1","user2","user3"};
  18. char *pcpwd[3]={"Potato","Tomato","Turnip"};
  19. int l,p,i,c;
  20. char login[5];
  21. char password[6];
  22. printf("\n\n\n\n\t\tEmployee Information System\n");
  23. printf("\t\t===========================\n\n");
  24. printf("\t\tLogin Screen\n");
  25. printf("\t\t============\n");
  26. printf("\n\t\tEnter User Id\t: ");
  27. scanf("%s",&login);
  28. printf("\n\t\tEnter Password\t: ");
  29. scanf("%s",&password);
  30.  
  31.  
  32.  
  33. //l=strcmp(&loginid[i], login);
  34. //p=!strcmp(&pwd[i],password);
  35.  
  36. password[c]= password[6];
  37. printf("*");
  38. for(c=0;c<=6;c++)
  39.  
  40. {
  41. if( l=p)
  42. printf("LOGIN ACCEPTED");
  43. else
  44. printf("LOGIN DENIED");
  45.  
  46. exit;
  47. }
  48. }

But again, What the **** are you trying to do with this code???

ok...well..we were given this assignment to do a case senitive comaprison for teh password and a case insensitive comparison for the login..and show a "*" when we accept passwords form users..typical like gmail/orkut or for that matter daniweb...

thats what i did..and In my 17 years of studying, I have never ever undergone soft-skills training...so I guess that would account for the logic and syntax deprived code..!!

ofcourse there were examples of programs using logical operands like || but somehow I wanted to make it this way..

one more thins, since strcmp returns ansi c value and for everymatch, it returns 0, shouldnt l and p be equal to o..?

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

Re: Compiling errors with braces!

ahh!!

again, I feel there is a bug in Visual C++ 6.0 because my compiler seems hung-up on the braces!!!!

errors after compiling the above mentioned code-
practice1.c
- C:\Program Files\Microsoft Visual Studio\MyProjects\practice\practice1.c(46) : warning C4550: expression evaluates to a function which is missing an argument list
- C:\Program Files\Microsoft Visual Studio\MyProjects\practice\practice1.c(19) : warning C4101: 'i' : unreferenced local variable
- C:\Program Files\Microsoft Visual Studio\MyProjects\practice\practice1.c(57) : error C2084: function 'int __cdecl main(int ,char ** )' already has a body
- C:\Program Files\Microsoft Visual Studio\MyProjects\practice\practice1.c(64) : error C2084: function 'void __cdecl fnlogincheck()' already has a body
- C:\Program Files\Microsoft Visual Studio\MyProjects\practice\practice1.c(94) : warning C4550: expression evaluates to a function which is missing an argument list
Error executing cl.exe.

practice1.obj - 2 error(s), 3 warning(s)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
orthographer is offline Offline
14 posts
since Jan 2009
Jan 28th, 2009
0

Re: Compiling errors with braces!

How can you put p=o?

P is a integer. Do you even know what a integer is?
Reputation Points: 49
Solved Threads: 1
Posting Whiz in Training
riahc3 is offline Offline
298 posts
since May 2008
Jan 28th, 2009
0

Re: Compiling errors with braces!

BTW use wvDev-C++; Much better IDE.
Reputation Points: 49
Solved Threads: 1
Posting Whiz in Training
riahc3 is offline Offline
298 posts
since May 2008
Jan 28th, 2009
0

Re: Compiling errors with braces!

Click to Expand / Collapse  Quote originally posted by riahc3 ...
How can you put p=o?

P is a integer. Do you even know what a integer is?
Even if I (or for that matter anyonw who has reached here) would not be a programmer, I would still know what an integer is!!


The question here is not whether we can allot value like zero to it, but to the best of my knowledge, on making a case insensitive/sensitive comparison for two strings, a differnce is returned if they are not found to be equal..(diffrnce of ansi c values)

Now for both the cases we are comparing strings with unequal lengths, login has a strlen of 5 characters and pwd has 6 characters..

how can we equate l to p?

the whole point of me making l =0 and p=0 was to make sure that l and p accept values which are already defined in the arrays!

still, I might be wrong, feel free to correct me.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
orthographer is offline Offline
14 posts
since Jan 2009
Jan 28th, 2009
0

Re: Compiling errors with braces!

and why cant 0 be allotted to an integer, initializing loops and allotting null to an integer always involves setting pointers on zero!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
orthographer is offline Offline
14 posts
since Jan 2009

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: How to define MSWIN
Next Thread in C Forum Timeline: Image rotation





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


Follow us on Twitter


© 2011 DaniWeb® LLC