Print new line from String to file

Discussion in 'C Programming' started by meendar, Sep 14, 2007.

  1. meendar

    meendar Guest

    Hi,

    I have an string which is to be appended to some file, if i need
    inserting newline within the string what should i do with the String?
    i.e.. anything possible as like the example..,


    char *c ="This is first line \n
    This is second line \n
    This is third line \n"


    some a.txt:

    This is first line
    This is second line
    This is third line

    Thanks in Advance!
     
    meendar, Sep 14, 2007
    #1
    1. Advertising

  2. meendar

    jaysome Guest

    On Thu, 13 Sep 2007 23:44:04 -0700, meendar
    <> wrote:

    >Hi,
    >
    >I have an string which is to be appended to some file, if i need
    >inserting newline within the string what should i do with the String?
    >i.e.. anything possible as like the example..,
    >
    >
    >char *c ="This is first line \n
    > This is second line \n
    > This is third line \n"
    >
    >
    >some a.txt:
    >
    >This is first line
    >This is second line
    >This is third line
    >
    >Thanks in Advance!


    #include <stdio.h>
    int main(void)
    {
    const char *lines =
    "This is first line\n"
    "This is second line\n"
    "This is third line\n";
    printf("%s", lines);
    return 0;
    }

    --
    jay
     
    jaysome, Sep 14, 2007
    #2
    1. Advertising

  3. meendar

    meendar Guest

    On Sep 14, 3:14 am, jaysome <> wrote:
    > On Thu, 13 Sep 2007 23:44:04 -0700, meendar
    >
    >
    >
    > <> wrote:
    > >Hi,

    >
    > >I have an string which is to be appended to some file, if i need
    > >inserting newline within the string what should i do with the String?
    > >i.e.. anything possible as like the example..,

    >
    > >char *c ="This is first line \n
    > > This is second line \n
    > > This is third line \n"

    >
    > >some a.txt:

    >
    > >This is first line
    > >This is second line
    > >This is third line

    >
    > >Thanks in Advance!

    >
    > #include <stdio.h>
    > int main(void)
    > {
    > const char *lines =
    > "This is first line\n"
    > "This is second line\n"
    > "This is third line\n";
    > printf("%s", lines);
    > return 0;
    >
    > }
    >
    > --
    > jay


    Thanks jay
     
    meendar, Sep 14, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keto
    Replies:
    0
    Views:
    1,000
  2. meendar

    Print new line from String to file

    meendar, Sep 14, 2007, in forum: C Programming
    Replies:
    0
    Views:
    266
    meendar
    Sep 14, 2007
  3. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    374
    David Cournapeau
    Dec 30, 2008
  4. scad
    Replies:
    23
    Views:
    1,196
    Alf P. Steinbach
    May 17, 2009
  5. Janus Bor
    Replies:
    6
    Views:
    117
    Dave Bass
    Jul 16, 2008
Loading...

Share This Page