Compiling errors with braces!

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2009
Posts: 14
Reputation: orthographer is an unknown quantity at this point 
Solved Threads: 0
orthographer orthographer is offline Offline
Newbie Poster

Compiling errors with braces!

 
0
  #1
Jan 28th, 2009
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. .
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 14
Reputation: orthographer is an unknown quantity at this point 
Solved Threads: 0
orthographer orthographer is offline Offline
Newbie Poster

Re: Compiling errors with braces!

 
0
  #2
Jan 28th, 2009
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)
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 82
Reputation: riahc3 is an unknown quantity at this point 
Solved Threads: 0
riahc3 riahc3 is offline Offline
Junior Poster in Training

Re: Compiling errors with braces!

 
0
  #3
Jan 28th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 82
Reputation: riahc3 is an unknown quantity at this point 
Solved Threads: 0
riahc3 riahc3 is offline Offline
Junior Poster in Training

Re: Compiling errors with braces!

 
0
  #4
Jan 28th, 2009
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???
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 14
Reputation: orthographer is an unknown quantity at this point 
Solved Threads: 0
orthographer orthographer is offline Offline
Newbie Poster

Re: Compiling errors with braces!

 
0
  #5
Jan 28th, 2009
Originally Posted by riahc3 View Post
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 14
Reputation: orthographer is an unknown quantity at this point 
Solved Threads: 0
orthographer orthographer is offline Offline
Newbie Poster

Re: Compiling errors with braces!

 
0
  #6
Jan 28th, 2009
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)
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 82
Reputation: riahc3 is an unknown quantity at this point 
Solved Threads: 0
riahc3 riahc3 is offline Offline
Junior Poster in Training

Re: Compiling errors with braces!

 
0
  #7
Jan 28th, 2009
How can you put p=o?

P is a integer. Do you even know what a integer is?
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 82
Reputation: riahc3 is an unknown quantity at this point 
Solved Threads: 0
riahc3 riahc3 is offline Offline
Junior Poster in Training

Re: Compiling errors with braces!

 
0
  #8
Jan 28th, 2009
BTW use wvDev-C++; Much better IDE.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 14
Reputation: orthographer is an unknown quantity at this point 
Solved Threads: 0
orthographer orthographer is offline Offline
Newbie Poster

Re: Compiling errors with braces!

 
0
  #9
Jan 28th, 2009
Originally Posted by riahc3 View Post
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.
Modesty is the true virtue of the educated. Conceit always comes as a bonus to the hollow and haughty..!

Know thyself..
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 14
Reputation: orthographer is an unknown quantity at this point 
Solved Threads: 0
orthographer orthographer is offline Offline
Newbie Poster

Re: Compiling errors with braces!

 
0
  #10
Jan 28th, 2009
and why cant 0 be allotted to an integer, initializing loops and allotting null to an integer always involves setting pointers on zero!
Modesty is the true virtue of the educated. Conceit always comes as a bonus to the hollow and haughty..!

Know thyself..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC