Total members 10249 | Gratitudes |It is currently Thu May 17, 2012 8:04 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: getting a full line input
PostPosted: Sat Nov 08, 2008 10:55 pm 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
Have thanks: 1 time

In a pgm,if the input is a single line or several lines,what is the
statement i have to give.I have to get the input as a whole.


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: getting a full line input
PostPosted: Sat Nov 08, 2008 10:56 pm 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:53 pm
Posts: 229
Has thanked: 0 time
Have thanks: 0 time
I _suggest_ that you mean the following:

You have a program which works on standard input. No matter whether
this standard input consists of no input, one single line, or many
lines of input, you have to process this input as a whole.

Is my understanding correct?

If so, in C you might want to use fread() in a loop until feof() is true:
Code:
while (1)
{ if (fread( myBuffer, 1, sizeof( myBuffer), inputFile) !=
sizeof( myBuffer))
break; /* end of file reached or error occurred */
if (feof( inputFile))
break;
...
}


Within this loop, append the current buffer content to the whole input
that you've read so far.
Before doing so, you should check whether the piece of memory you have
allocated for the whole input is large enough to hold the current
contents of "myBuffer"; if not, you will have to reallocate this
memory or react in some other useful way (for example, terminate the
program after printing an error message).


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 Changing the line height of the paragraph
 draw a horizontal line in your html page
 start a new line in html
 Google Chrome input file
 How to show full resolution image at clicking on thumnail
 Java Websphere Portal Developer Full-time position in IL
 getting file name of html input file tag using jsp
 Full Encription System (DES-AES,RSA and more)
 Command line chat (client and server)
 Help needed to verify a new on-line C test

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 3 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team