Results 1 to 6 of 6

Thread: C++ File I/O???

  1. #1

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Question C++ File I/O???

    How much faster is c++ file I/O than VB's?

    Would it make a program alot faster if i wrote a dll file in c++ to read a file into array so that vb can access it. If it is faster is there a tutorial that would help me learn how to do this. or could some one post a example?

    Thanx <ABX!
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    You shouldnt be reading or writing to a file very often (unless you are writing some sort of specialized database), so the speed really doesnt matter. In reality, both are calling the Win API, so the speed difference is negligable.

    Z.

  3. #3

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    How about Reading a 200kb text file into a array

    I thought c++ was suspose to be alot faster for file access?
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  4. #4

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    I Guess C++ Forums not as busy as vb???
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Originally posted by &lt;ABX
    How about Reading a 200kb text file into a array

    I thought c++ was suspose to be alot faster for file access?
    It's faster for the actual processing on that data, in most cases.

    I wouldn't worry about it.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    I/O speeds are related far more to hardware than the language.
    A disk with high latency, slow rotation, and lots of fragmentation is far more of a problem.

    CPU and primary bus throughput speeds (software) are usually 100 - 1000 times faster than disk i/o. This is why most disks have 1-10MB+ of onboard cache. It's essentially a readahead buffer. If you want to maximize the use of the cache read the entire file at once then close it. This is only going to help with large files. This is because Windows has a RAM cache of usually 64kb for all open files. This will handle little files - the disk cache is meant for biggies.

    VB code (sorry not C++)
    Code:
    dim tmp() as string
    dim a as string
    open "myfile.txt" for binary as #1
    a= space(LOF(1))
    get #1,,a
    close #1
    tmp=split(a,VbCrLf)

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