| | |
HELP..!!
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
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
}
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
}
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).
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
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
c Syntax (Toggle Plain Text)
. . 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 } heres the code...and the explanation as to what is wrong, is in the original post( very1st post).. thnx.. . .
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.
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.
* 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.
* 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
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Jan 2009
Posts: 14
Reputation:
Solved Threads: 0
•
•
•
•
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.
![]() |
Other Threads in the C Forum
- Previous Thread: Image rotation
- Next Thread: If else statement
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks bash binarysearch centimeter changingto char character convert copyimagefile cprogramme creafecopyofanytypeoffileinc database dynamic execv feet fgets file floatingpointvalidation fork framework function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop initialization input interest intmain() iso kernel keyboard kilometer license linked linkedlist linux list lists locate looping lowest matrix meter microsoft number oddnumber opendocumentformat openwebfoundation overwrite owf pdf pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing scripting segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test testing threads turboc unix urboc user variable wab whythiscodecausesegmentationfault windowsapi






