Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Print new line from String to file

Reply
Thread Tools

Print new line from String to file

 
 
meendar
Guest
Posts: n/a
 
      09-14-2007
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!

 
Reply With Quote
 
 
 
 
jaysome
Guest
Posts: n/a
 
      09-14-2007
On Thu, 13 Sep 2007 23:44:04 -0700, meendar
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
meendar
Guest
Posts: n/a
 
      09-14-2007
On Sep 14, 3:14 am, jaysome <(E-Mail Removed)> wrote:
> On Thu, 13 Sep 2007 23:44:04 -0700, meendar
>
>
>
> <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read a file line by line and write each line to a file based on the5th byte scad C++ 23 05-17-2009 06:11 PM
Print new line from String to file meendar C Programming 0 09-14-2007 06:41 AM
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
Read a file line by line with a maximum number of characters per line Hugo Java 10 10-18-2004 11:42 AM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments