Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Translate

Translate

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hest
    wrote on last edited by
    #1

    Hi, I'm having some problems reading a file containing null-terminations. When I try reading the file into a string, it stops at the first binary null ('\0'). On unix we have an excellent command, the tr command. It would solve the problem: To delete all NULL characters from a file, enter: tr -d '\0' < textfile > newfile Is there a way of either translating the NULL's, removing them or even skipping them? If anyone have suggestions, please respond.

    X J 2 Replies Last reply
    0
    • H hest

      Hi, I'm having some problems reading a file containing null-terminations. When I try reading the file into a string, it stops at the first binary null ('\0'). On unix we have an excellent command, the tr command. It would solve the problem: To delete all NULL characters from a file, enter: tr -d '\0' < textfile > newfile Is there a way of either translating the NULL's, removing them or even skipping them? If anyone have suggestions, please respond.

      X Offline
      X Offline
      xi904
      wrote on last edited by
      #2

      You can use memcpy to reading the file into a string. You need to get the string's pointer first.

      1 Reply Last reply
      0
      • H hest

        Hi, I'm having some problems reading a file containing null-terminations. When I try reading the file into a string, it stops at the first binary null ('\0'). On unix we have an excellent command, the tr command. It would solve the problem: To delete all NULL characters from a file, enter: tr -d '\0' < textfile > newfile Is there a way of either translating the NULL's, removing them or even skipping them? If anyone have suggestions, please respond.

        J Offline
        J Offline
        jhwurmbach
        wrote on last edited by
        #3

        If you just need the whole files content, without any line-breaks etc, reading it in binary mode is the way to go. Then you can copy it into a std::vector < char > , and use std:: algorithms on it. -- "My opinions may have changed, but not the fact that I am right." Found in the sig of Herbert Kaminski

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups