Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Files related

Files related

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rajanponnalagu
    wrote on last edited by
    #1

    Hello, I have created one MFC Application for User login page. I have created 2 dialog boxes. One dialog box contains username and password, when i press Create new account button, there is another dialog box will open. There i have given the username, password and confirm password. The problem is if i click the submit button in 2nd dialog, only one character has to be stored in the file. I want to store the entire text in the file. How can I do that?. Please help on this. Thanks in advance.

    L P 2 Replies Last reply
    0
    • R rajanponnalagu

      Hello, I have created one MFC Application for User login page. I have created 2 dialog boxes. One dialog box contains username and password, when i press Create new account button, there is another dialog box will open. There i have given the username, password and confirm password. The problem is if i click the submit button in 2nd dialog, only one character has to be stored in the file. I want to store the entire text in the file. How can I do that?. Please help on this. Thanks in advance.

      L Offline
      L Offline
      Llasus
      wrote on last edited by
      #2

      can you paste the code on that part? so we will know what the error is.

      R 1 Reply Last reply
      0
      • L Llasus

        can you paste the code on that part? so we will know what the error is.

        R Offline
        R Offline
        rajanponnalagu
        wrote on last edited by
        #3

        Hello, Thanks a lot for reply. I attached the source code below: If i click the submit button the following code is executing. -------------------------------------------------------------- FILE *fleCredentials; try { // Create a new file or open the existing one fleCredentials = fopen("credentials.crd", "a+"); { // Add the username to the file // fprintf(fleCredentials, "%s ", (LPCTSTR)m_Username); // Add the password to the file fprintf(fleCredentials, "%s\n", (LPCTSTR)m_Password); } // After using it, close the file fclose(fleCredentials); --------------------------------------------------------

        S D 2 Replies Last reply
        0
        • R rajanponnalagu

          Hello, I have created one MFC Application for User login page. I have created 2 dialog boxes. One dialog box contains username and password, when i press Create new account button, there is another dialog box will open. There i have given the username, password and confirm password. The problem is if i click the submit button in 2nd dialog, only one character has to be stored in the file. I want to store the entire text in the file. How can I do that?. Please help on this. Thanks in advance.

          P Offline
          P Offline
          Paresh Chitte
          wrote on last edited by
          #4

          Could you please post the code snippet ? Regards, Paresh.

          R 1 Reply Last reply
          0
          • P Paresh Chitte

            Could you please post the code snippet ? Regards, Paresh.

            R Offline
            R Offline
            rajanponnalagu
            wrote on last edited by
            #5

            I have given the code snippet where i can get the problem.

            1 Reply Last reply
            0
            • R rajanponnalagu

              Hello, Thanks a lot for reply. I attached the source code below: If i click the submit button the following code is executing. -------------------------------------------------------------- FILE *fleCredentials; try { // Create a new file or open the existing one fleCredentials = fopen("credentials.crd", "a+"); { // Add the username to the file // fprintf(fleCredentials, "%s ", (LPCTSTR)m_Username); // Add the password to the file fprintf(fleCredentials, "%s\n", (LPCTSTR)m_Password); } // After using it, close the file fclose(fleCredentials); --------------------------------------------------------

              S Offline
              S Offline
              Sunil Shindekar
              wrote on last edited by
              #6

              What is the data type of m_Username and m_Password?

              R 1 Reply Last reply
              0
              • S Sunil Shindekar

                What is the data type of m_Username and m_Password?

                R Offline
                R Offline
                rajanponnalagu
                wrote on last edited by
                #7

                m_username and m_password are CString types.

                I S 2 Replies Last reply
                0
                • R rajanponnalagu

                  m_username and m_password are CString types.

                  I Offline
                  I Offline
                  Iain Clarke Warrior Programmer
                  wrote on last edited by
                  #8

                  If you use the debugger at that function to save the two files, I bet you get... m_User = "user" and m_Pass = "pass" (I can't see your original code) And then your text file will be.... userpass with no way of know where one starts, and the other finishes... Instead of CString, try using a fixed character array, and then saving that out. It will be much easier when you load it. It will have the restriction of only being able to have user names and passwords of a certain length, so don't make it too short! Iain.

                  1 Reply Last reply
                  0
                  • R rajanponnalagu

                    m_username and m_password are CString types.

                    S Offline
                    S Offline
                    Sunil Shindekar
                    wrote on last edited by
                    #9

                    Try using GetBuffer() function for the CString objects in the fprintf statement?

                    D 1 Reply Last reply
                    0
                    • S Sunil Shindekar

                      Try using GetBuffer() function for the CString objects in the fprintf statement?

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #10

                      No, don't do that at all. :rolleyes: The GetBuffer() method should only be used when write access to the internal buffer is required. In this case, it is not. The LPCTSTR operator is all that's needed.

                      "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                      1 Reply Last reply
                      0
                      • R rajanponnalagu

                        Hello, Thanks a lot for reply. I attached the source code below: If i click the submit button the following code is executing. -------------------------------------------------------------- FILE *fleCredentials; try { // Create a new file or open the existing one fleCredentials = fopen("credentials.crd", "a+"); { // Add the username to the file // fprintf(fleCredentials, "%s ", (LPCTSTR)m_Username); // Add the password to the file fprintf(fleCredentials, "%s\n", (LPCTSTR)m_Password); } // After using it, close the file fclose(fleCredentials); --------------------------------------------------------

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #11

                        How are you verifying that only two characters (one from each variable) exist in the file? Is this a Unicode application?

                        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups