Thread: Binary to Ascii Conversion

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    1

    Binary to Ascii Conversion

    Hi

    I am using c code to convert a binary .DAT file to a ASCII format file.

    Code to convert binary character to ascii character is something like below:

    memcpy(Asc->ClnCode,Bin->ClnCode,5);
    Asc->CustCode[5]='\0';

    The problem is if i give the filename of binary file in argument to the executable then it is not able to read the file saying "File not found"
    Even though the file is present in the given path.
    Eg:
    Filename=B_ABCDE_07060304.DAT
    If i change the filename to B_ABCDE_.DAT it reads the file properly.
    Is there any limitation to filename characters in C
    I am using TruboC++ compiler using following command to open the file.
    fp = fopen( binfile, "rb");

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    Apparently your code cannot read long file names. You'll have to input the equivalent of the long file name to your executable. At the command prompt in the directory where your file is located, execute the following command:

    DIR /X

    This will display both the long file name and the 8.3 DOS file name. Input the 8.3 DOS file name to your executable. The DOS equivalent should be something like B_ABCD~1.DAT.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    This is a result of using Turbo. Old DOS compilers cannot use long Windows filenames, even though the same code compiled with a modern compiler can. I'd suggest getting a newer compiler.

    For example, try Dev-C++: http://bloodshed.net/devcpp.html
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 03:27 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. binary to ASCII conversion
    By loaded_tk in forum C Programming
    Replies: 3
    Last Post: 03-01-2006, 09:28 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM