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. Mobile Development
  3. Mobile
  4. Urgent! FileI/O Problem

Urgent! FileI/O Problem

Scheduled Pinned Locked Moved Mobile
c++helpquestionhardware
8 Posts 5 Posters 21 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi all, I am using Embedded Visual C++ 3.0 and MFC dialog mode for implementation. Firstly, if I want to read one line each time from a .txt file in Pocket PC, can I use the following code? char* data; data = NULL; fp=fopen("\\sip.txt","r"); while((!feof(fp)) && (fp != NULL)) { fscanf(fp, "%s", data); // Process the data here } fclose(fp); Then, if I want to get the typed message from an edit box in a MFC dialog box and write/ append it into the file each time a line, should I do this? CString asip; GetDlgItemText(INPUT_ASIP, asip); fp=fopen("\\sip.txt","a"); fprintf(fp, "%s\n", asip); fclose(fp); But I encounter a problem that the output file “sip” contains only the first character of the CString asip. How can I solve this? It’s really urgent as I have to hand the program before 26/3/2003 so please kindly help me. Many thanks!!! Wil

    J 1 Reply Last reply
    0
    • A Anonymous

      Hi all, I am using Embedded Visual C++ 3.0 and MFC dialog mode for implementation. Firstly, if I want to read one line each time from a .txt file in Pocket PC, can I use the following code? char* data; data = NULL; fp=fopen("\\sip.txt","r"); while((!feof(fp)) && (fp != NULL)) { fscanf(fp, "%s", data); // Process the data here } fclose(fp); Then, if I want to get the typed message from an edit box in a MFC dialog box and write/ append it into the file each time a line, should I do this? CString asip; GetDlgItemText(INPUT_ASIP, asip); fp=fopen("\\sip.txt","a"); fprintf(fp, "%s\n", asip); fclose(fp); But I encounter a problem that the output file “sip” contains only the first character of the CString asip. How can I solve this? It’s really urgent as I have to hand the program before 26/3/2003 so please kindly help me. Many thanks!!! Wil

      J Offline
      J Offline
      Joao Paulo Figueira
      wrote on last edited by
      #2

      The PocketPC only supports UNICOD through TCHAR, not char. You have to rewrite everything in order to use TCHAR.

      W D 2 Replies Last reply
      0
      • J Joao Paulo Figueira

        The PocketPC only supports UNICOD through TCHAR, not char. You have to rewrite everything in order to use TCHAR.

        W Offline
        W Offline
        williamking
        wrote on last edited by
        #3

        ok, THX ! Wil

        J 1 Reply Last reply
        0
        • W williamking

          ok, THX ! Wil

          J Offline
          J Offline
          Joao Paulo Figueira
          wrote on last edited by
          #4

          Is it just me, or is this messaging system really typo-prone? I meant UNICODE, of course... ;)

          realJSOPR 1 Reply Last reply
          0
          • J Joao Paulo Figueira

            Is it just me, or is this messaging system really typo-prone? I meant UNICODE, of course... ;)

            realJSOPR Online
            realJSOPR Online
            realJSOP
            wrote on last edited by
            #5

            "UNICOD" is a new scientifically engineered generic fish, guaranteed to be edible, even in Fance. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

            J 1 Reply Last reply
            0
            • realJSOPR realJSOP

              "UNICOD" is a new scientifically engineered generic fish, guaranteed to be edible, even in Fance. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

              J Offline
              J Offline
              Joao Paulo Figueira
              wrote on last edited by
              #6

              John Simmons / outlaw programmer wrote: "UNICOD" is a new scientifically engineered generic fish, guaranteed to be edible, even in Fance. :laugh: If you ever come to Portugal, try the 1000 ways of cooking cod. D E L I C I O U S ;)

              1 Reply Last reply
              0
              • J Joao Paulo Figueira

                The PocketPC only supports UNICOD through TCHAR, not char. You have to rewrite everything in order to use TCHAR.

                D Offline
                D Offline
                dlhson2
                wrote on last edited by
                #7

                I don't think so. I've tested char on PocketPC with C/C++ runtime library (FILE*). It works normally. FILE * g; if (g=fopen("abc.txt","rt")) { char szStr[255]; fgets(szStr,255,g); CString strMsg; strMsg = "Read text: "; strMsg+= szStr; MessageBox(strMsg); } Of course, the file is just in ANSI charset. ======================= Nothing is perfect

                J 1 Reply Last reply
                0
                • D dlhson2

                  I don't think so. I've tested char on PocketPC with C/C++ runtime library (FILE*). It works normally. FILE * g; if (g=fopen("abc.txt","rt")) { char szStr[255]; fgets(szStr,255,g); CString strMsg; strMsg = "Read text: "; strMsg+= szStr; MessageBox(strMsg); } Of course, the file is just in ANSI charset. ======================= Nothing is perfect

                  J Offline
                  J Offline
                  Joao Paulo Figueira
                  wrote on last edited by
                  #8

                  I'm not sure of what might be happening, but some of the functions might be expecting TCHAR* instead of char*, although the compiler should complain about this. Is there anything wrong in the file itself? Why not use MFC's CFile?

                  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