Results 1 to 6 of 6

Thread: little program, help needed

  1. #1

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    little program, help needed

    I need a small program, and I'm stuck.
    The program should read in an entire file and remove everything between two control phrases (including the control phrases). It should then write the result to a new file.
    The control phrases are:
    //!!COMMENT marks the start
    ENDCOMMENT!!// marks the end
    Th program should be a console app called like this:
    program srcfile dstfile

    Is there anything available or has anybody got tips for me?
    How do you get the file length? How do you edit the puffer?

    Thx in advance

    All the buzzt
    CornedBee

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Have a look at the Stream I/O routines on msdn site
    http://msdn.microsoft.com/library/de...eam_i.2f.o.asp
    or if you want the more speedy variant, File I/O Reference
    http://msdn.microsoft.com/library/de...lesio_4lf7.asp
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I have a local msdn version, but I can't find the functions to get the file length. And the documentations of the STL and stream classes sucks. I can't find anything there.
    Maybe you have function names that I can look up? Or should I switch to API calls?

    All the buzzt
    CornedBee

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    To get the file length, first open the file using fopen(). Then use
    Code:
    fseek(Pointer to FILE structure,0,SEEK_END);
    long filelength = ftell(Pointer to FILE structure);
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Thanks, it's useless anyway because the file format sucks (it's not plain text), so I can't do what I wanted.
    I'll know next time, so thanks anyway.

    All the buzzt
    CornedBee

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Go with win32 api
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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