CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2009
    Posts
    6

    Read text file in VC++

    Hello every one,

    I am new in C++ and I have a new project.
    I have a text file with numbers that are coordinates x,y

    The text files´s format looks like this:

    X Y

    234 5678
    243 3456
    193 235
    1234 345

    and so on

    Steps,

    1.- Put all this file in a buffer memory (unsigned char inbuffer [2000],
    2.- Display each two coordinates in two text box one for X and one for Y (I dont´t know how to do this)
    3.- inbuffer [0] = outbuffer[0]
    inbuffer [1] = outbuffer[1]

    4.-increment inbuffer + 2 for next two coordinates
    5.-Put this data in USB (Resolved)
    6.-Microcontroller sends ready bit to receive more data (resolved)
    7.-Repeat from step 2 until all data is sended.
    I really appreciate your help with a little code.

    Regards
    Carlos

  2. #2
    Join Date
    Jul 2010
    Posts
    31

    Re: Read text file in VC++


  3. #3
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Read text file in VC++

    You can use fstream to read text file that will be even easy and simple.
    Code:
    ifstream fileRead("your file");
    while ( ! fileRead.eof() )
    {
      /** Do your stuffs here **/
    }
    In the stuff part you need to manipulate text file reading as per your need. Like you can read line by line in char* by getline() and break into two char* if a space found ie: the delim of getline() and if '\n' found go to next line and read it, and so on, using a loop.

  4. #4
    Join Date
    Apr 2009
    Posts
    6

    Re: Read text file in VC++

    Thanks for your reply, but can you tell me where the file is stored?

  5. #5
    Join Date
    Jul 2009
    Posts
    37

    Re: Read text file in VC++

    What file ?
    Sig-na-tju-(r)

  6. #6
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Read text file in VC++

    Which file. No file is storing here. You need to input file name, the file you want to read

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured