[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Login, Help me 2 more day to pass up to sch

Posted on 2004-04-10
9
Medium Priority
?
181 Views
Last Modified: 2010-04-15
i dont know whats is wrong.
I save the file as the username but when the user key in the username, the loop will not go to the /*if loop*/ when the key in username is correct.
 
  This is my LOGIN CODE
   printf("\n\t\tEnter username: ");
   gets(user);
   filename = user;
   if((fs = fopen(filename, "r"))==NULL)
   {          
              system("cls");
              printf("\n\n\n\t\t\tUsername not Registered!!
                        \n\n\t\t\tPlease register Yourself.\n\n\t\t\t");
              system("pause");
              main();
   }
   else
   {
               verif();
               fclose(fs);
                                     
   }

      verif() //This is only a part of it, what is wrong
         printf("\n\t\tPlease enter your username: ");
         gets(user);
         filename = user;
         fs = fopen(filename, "w");
         for(x=0; x<8; x=x+1) //This is where i save my password
          {
                fprintf(fs,"%c", pw[x]);
          }
          fclose(fs);
0
Comment
Question by:HonAlan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
9 Comments
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10797371
do
strcpy(filename,user);
instead of
filename=user;
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10797377
>for(x=0; x<8; x=x+1) //This is where i save my password

for(x=0; x<strlen(user); x=x+1)
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10797388
>for(x=0; x<strlen(user); x=x+1)
should be
for(x=0; x<strlen(pw); x=x+1)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 9

Expert Comment

by:ankuratvb
ID: 10797412
>I save the file as the username but when the user key in the username, the loop will not >go to the /*if loop*/ when the key in username is correct.
//if the file does not exist then executes the if portion,so if user exists it will not execute this
  if((fs = fopen(filename, "r"))==NULL)
  {          
             system("cls");
             printf("\n\n\n\t\t\tUsername not Registered!!
                       \n\n\t\t\tPlease register Yourself.\n\n\t\t\t");
             system("pause");
             main();//why this call???
  }
  else //else this part
  {
              verif();
              fclose(fs);
                                     
  }
0
 

Author Comment

by:HonAlan
ID: 10797496
i have solve the problem myself thanks. I have alot of void function but how do i take the username in the other function and put the username into another function. No global variable are allowed. global function can.

         void LOGIN
          gets(user);
          filename = user
          fs = fopen(filename, "r");

        void changingPassword
           //what should i put here
           fs = fopen(filename, "r");
0
 

Expert Comment

by:ramavorray
ID: 10798355
Dlete the old file name by asking user to supply his old password along with his new password.
delete a file by suing system() function and dos command to delete a file
Create a new filename
use fopen("<filename>", "w");

Hope this helps
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10799723
use the remove fn. to remove a file.

remove("filename.txt");

and for creating a new file with the changed password,use the write mode(as ramavorray pointed out)
0
 

Author Comment

by:HonAlan
ID: 10800682
that is not what i meant.
   void LOGIN
          gets(user); //In login, i must get the username first
          filename = user  //then filename = user
          fs = fopen(filename, "r"); //then read filename as
                                                 the username

    void changingPassword
     //if i want to get the username  that the user key in in the void LOGIN() but i dont want to 'gets(user);' here again to get the username.
 
           //what should i put here to so that filename = ?
           fs = fopen(filename, "r"); /*so that i can read the same file*/
         
0
 
LVL 9

Accepted Solution

by:
ankuratvb earned 120 total points
ID: 10800742
Pass the filename as an argument to the function changingpassword()

void changingpassword(char *filename)
{
  fs = fopen(filename, "r"); /*so that i can read the same file*/
}


call it using:
void LOGIN()
         gets(user); //In login, i must get the username first
         filename = user  //then filename = user
         fs = fopen(filename, "r"); //then read filename as
                                                the username
         changingpassword(filename);
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question