CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Borland C++

  1. #1
    Join Date
    Oct 2004
    Posts
    97

    Borland C++

    Im trying to read from a file using Borland C++ but im haveing a problem reading from a file

    Code:
    int TForm1::LoadFile()
    {
       ifstream filein;
       string inchar;
       memblock;
    
       filein.open("FileCabenet\\StockUpdates\\datalink.txt");
    
       while (filein.good())
       {
         filein >> inchar;
    
         memblock.append(inchar);
       }
    
       filein.close();
       return 1;
    }
    Code:
    The File
    
    "PRICE","PRODUCT_CODE","STOCK_AVAILABLE","CATEGORY_TIER1","CATEGORY_TIER2","CATEGORY_TIER3","SHORT_DESCRIPTION","LONG_DESCRIPTION","WEB_LINK","WEIGHT"
    The Problem I’m having when I read in it adds a \ in front of the " and i cant work out why

  2. #2
    Join Date
    Jun 2002
    Posts
    224

    Re: Borland C++

    Hello,

    I assume:
    Code:
       string inchar;
       memblock;
    should be:
    Code:
       string inchar, memblock;
    I reckon you did not post the actual code. The code you posted (with the above correction) works fine on my compiler (VC7).
    ZDF

    What is good is twice as good if it's simple.
    "Make it simple" is a complex task.

  3. #3
    Join Date
    Oct 2004
    Posts
    97

    Re: Borland C++

    yeah sorry memblock is defined else where in the code.

    The Problem im havening is Borland C++ 6 seems to be adding lines to the data not sure if its when im reading it in or saving it out to the file but when ever there is a \n in my file when i save it it adds a \r in front
    so
    Save one File is Fine
    Save two and \n now = \r\n
    save three "\r\r\n"
    save four "\r\r\r\n"

    Haven got a clue why it is doing this can anyone help?

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