| | |
Compiling errors with braces!
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
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***************
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***************
c Syntax (Toggle Plain Text)
. . #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #include<math.h> void fnlogincheck(); int 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("%s",&login); printf("\n\t\tEnter Password\t: "); scanf("%s",&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 } . .
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
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)
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)
•
•
Join Date: May 2008
Posts: 82
Reputation:
Solved Threads: 0
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:
Personally I think you come from another programming language that should either stick to it or reread from C manuals.
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:
C Syntax (Toggle Plain Text)
{ l=strcmp(&loginid[i], login); p=!strcmp(&pwd[i],password); for(i=o,i<=3,i++) } {
Personally I think you come from another programming language that should either stick to it or reread from C manuals.
•
•
Join Date: May 2008
Posts: 82
Reputation:
Solved Threads: 0
This complys:
But again, What the **** are you trying to do with this code???
C Syntax (Toggle Plain Text)
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #include<math.h> void fnlogincheck(); int 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("%s",&login); printf("\n\t\tEnter Password\t: "); scanf("%s",&password); //l=strcmp(&loginid[i], login); //p=!strcmp(&pwd[i],password); password[c]= password[6]; printf("*"); for(c=0;c<=6;c++) { if( l=p) printf("LOGIN ACCEPTED"); else printf("LOGIN DENIED"); exit; } }
But again, What the **** are you trying to do with this code???
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
•
•
•
•
This complys:
C Syntax (Toggle Plain Text)
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #include<math.h> void fnlogincheck(); int 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("%s",&login); printf("\n\t\tEnter Password\t: "); scanf("%s",&password); //l=strcmp(&loginid[i], login); //p=!strcmp(&pwd[i],password); password[c]= password[6]; printf("*"); for(c=0;c<=6;c++) { if( l=p) printf("LOGIN ACCEPTED"); else printf("LOGIN DENIED"); exit; } }
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
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
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)
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)
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
•
•
•
•
How can you put p=o?
P is a integer. Do you even know what a 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..
Know thyself..
![]() |
Similar Threads
- Function calling (C)
- compiler doesnt like my if/else statements?? (C++)
- compilation error (C++)
- major help (C++)
Other Threads in the C Forum
- Previous Thread: How to define MSWIN
- Next Thread: Image rotation
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks bash binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile creafecopyofanytypeoffileinc createprocess() database dynamic execv fgets file floatingpointvalidation fork framework function getlogicaldrivestrin givemetehcodez grade gtkwinlinux histogram ide inches include infiniteloop initialization input interest intmain() iso keyboard km license linked linkedlist linux list looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation owf pdf pointer pointers posix power probleminc process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing scheduling segmentationfault send sequential single socket socketprogramming standard strchr string suggestions systemcall test testautomation testing threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi





