Need help in writing to a file with delimeter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manjuks
    New Member
    • Dec 2007
    • 72

    Need help in writing to a file with delimeter

    Hi,

    I have some different types of data like

    Employee number
    Employee Name
    Employee sex
    .
    .
    .
    etc

    These Data I will read from stdin.

    These data I need to write to a file with pipe (|) as delimiter?
    How can I do this? Is there any library function for this.
    Please give me a pointer where I can get information on this.

    Thanks,
    Manjunath
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    | is just a character, write it to the file. It only has special meaning on the command line of Dos, Windows and *nix boxes. It has no special meaning in C or C++.

    Comment

    • manjuks
      New Member
      • Dec 2007
      • 72

      #3
      That means, there is no library function like fprintf. We need to write our own function to accomplish this.

      Thanks,
      Manjunath

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Where do you think fprintf originated? :D

        It's in C just check any standard library reference. But '|' has no special meaning in fprintf or any other C standard library function. The only characters with any special meaning in strings in C are \ which is the escape character indicating that what comes next has a special meaning and % which in *printf format strings starts a format specifier. There are no other characters in C that, taken alone, have special meanings in strings.

        Comment

        Working...