473,473 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

printing a block of text

Ed
Hi,

Could you tell me what the equivalent of this perl code would be in C
please?

print EOT<<
I want
to print over
multiple lines in c
without doing lots of printfs
EOT

Thanks!

Ed.

Sep 6 '06 #1
6 6588
In article <11**********************@p79g2000cwp.googlegroups .com>,
Ed <ed*********@hotmail.comwrote:
>Could you tell me what the equivalent of this perl code would be in C
please?
>print EOT<<
I want
to print over
multiple lines in c
without doing lots of printfs
EOT
#include <stdio.h>
int main(void) {
puts( "I want\nto print over\nmultiple lines in c\nwithout doing lots of printfs" );
return 0;
}

(Note: puts() automatically supplies the final \n )
--
Prototypes are supertypes of their clones. -- maplesoft
Sep 6 '06 #2
"Ed" <ed*********@hotmail.comwrites:
Could you tell me what the equivalent of this perl code would be in C
please?

print EOT<<
I want
to print over
multiple lines in c
without doing lots of printfs
EOT
fputs ("I want\n"
"to print over\n"
"multiple lines in c\n"
"without doing lots of printfs\n",
stdout);
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Sep 6 '06 #3
On Wed, 6 Sep 2006 21:43:43 +0000 (UTC), ro******@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
>#include <stdio.h>
int main(void) {
puts( "I want\nto print over\nmultiple lines in c\nwithout doing lots of printfs" );
return 0;
Or:

puts(
"I want\n"
"to print over\n"
"multiple lines in c\n"
"without doing lots of printfs\n"
);
--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Sep 6 '06 #4
Ed

Walter Roberson wrote:
In article <11**********************@p79g2000cwp.googlegroups .com>,
Ed <ed*********@hotmail.comwrote:
Could you tell me what the equivalent of this perl code would be in C
please?
print EOT<<
I want
to print over
multiple lines in c
without doing lots of printfs
EOT

#include <stdio.h>
int main(void) {
puts( "I want\nto print over\nmultiple lines in c\nwithout doing lots of printfs" );
return 0;
}

(Note: puts() automatically supplies the final \n )
--
Prototypes are supertypes of their clones. -- maplesoft
Thanks for that. Is there a way I can do it without having to specify
the \n's though?
I'm trying to print out an HTML page, so it'd make life easier if I
could do it in the Perl style above.

Sep 6 '06 #5
In article <11**********************@i3g2000cwc.googlegroups. com>,
Ed <ed*********@hotmail.comwrote:
>Thanks for that. Is there a way I can do it without having to specify
the \n's though?
I'm trying to print out an HTML page, so it'd make life easier if I
could do it in the Perl style above.
In short, NO: the alternatives are more complex and uglier.

--
Programming is what happens while you're busy making other plans.
Sep 6 '06 #6


Ed wrote On 09/06/06 17:52,:
Walter Roberson wrote:

>>In article <11**********************@p79g2000cwp.googlegroups .com>,
Ed <ed*********@hotmail.comwrote:

>>>Could you tell me what the equivalent of this perl code would be in C
please?
>>>print EOT<<
I want
to print over
multiple lines in c
without doing lots of printfs
EOT

#include <stdio.h>
int main(void) {
puts( "I want\nto print over\nmultiple lines in c\nwithout doing lots of printfs" );
return 0;
}

(Note: puts() automatically supplies the final \n )
--
Prototypes are supertypes of their clones. -- maplesoft


Thanks for that. Is there a way I can do it without having to specify
the \n's though?
I'm trying to print out an HTML page, so it'd make life easier if I
could do it in the Perl style above.
const char *text[] = {
"I want",
"to print over",
"multiple lines in c",
"without doing lots of printfs",
};
int i;
for (i = 0; i < sizeof text / sizeof text[0]; ++i)
puts(text[i]);

.... but it seems to me the embedded \n's are more convenient.
What's your problem with them?

--
Er*********@sun.com

Sep 6 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: java_helloworld | last post by:
I am trying to print from an applet using the Java Print API. If I run the applet on appletviewer then things work fine i.e. I am able to get the print out. If I run the applet on a browser then...
1
by: NickB | last post by:
Please could someone tell me what is wrong. Ther error is: An unhandled exception of type 'System.NullReferenceException' occurred in microsoft.visualbasic.dll Additional information: Object...
5
by: Mark Preston | last post by:
Admission first - I don't actually have a problem here but have noticed that a lot of people have been asking similar questions and getting very varied answers. What I've done is to sort of...
2
by: Rick | last post by:
Let me start by saying that I know very little about JavaScript. The software that I use to convert my FrameMaker files to HTML uses a JavaScript to hide certain text. The user has to click the...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
3
by: Jlcarroll | last post by:
Hi, I am building a web page.and have a simple javascript menu... I call the javascript menu within a div block that my print sytlesheet has set as a display: none;, well all the content in that...
7
by: johnacooke | last post by:
The W3C added THEAD, TFOOT and TBODY elements to facilitate the printing of long tables, so that header and footer information could be repeated on each page. While I have seen this discussed...
0
by: Iain Wilson | last post by:
I am pulling my hair out trying to print various objects from a .net web page My apologies for cross posting but I need an answer and my previous post has attracted no interest. ASP.Net 2.0...
10
by: Mtek | last post by:
Hi, I have a web page with some drop downs. Once the user makes his selections the bottom half of the page is populated. When that happens, I want to create a formatted report in a hidden div....
7
by: Iain Wilson | last post by:
I am pulling my hair out trying to print various objects from a .net web page My apologies for cross posting but I need an answer and my previous post has attracted no interest. ASP.Net 2.0...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.