Hi,
All I want is read input(it can be multiples lines) from console till it encounters EOF character.how can I handle multiple lines of string under one var?
Actually I tried to read
while((c=getchar())!=EOF) but it not works
Thanks,
Veera
Hi,
All I want is read input(it can be multiples lines) from console till it encounters EOF character.how can I handle multiple lines of string under one var?
Actually I tried to read
while((c=getchar())!=EOF) but it not works
Thanks,
Veera
Last edited by veera; 06-28-2015 at 12:41 PM.
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Below is my problem. Input
The first lines of the input is an integer N (1 <= N <= 1000). Next follows the input consisting of ASCII characters. The input is terminated by EOF character.
Length of each word is less than 1024 and maximum number of words can be never more than 1024.
Output
The input reversed N times with at least a space/newline between any two words of your output.
Example
Input:
2
Fox jumps over the lazy dog.
Output:
.god .god yzal yzal eht eht revo revo spmuj spmuj xoF xoF
Input:
1
It matters not how strait the gate,
How charged with punishments the scroll.
I am the master of my fate:
I am the captain of my soul.
Output:
.luos ym fo niatpac eht ma I
:etaf ym fo retsam eht ma I
.llorcs eht stnemhsinup htiw degrahc woH
,etag eht tiarts woh ton srettam tI
I think you missed:
1. Show your code
Lets say the file you have to read is T.txt, the methods for you to solve this problem is:
Traverse the file, store the integer somewhere & while traversing insert each ASCII character into a doubly linked list and print it as many times the integer in starting of file is given using some manipulation - rest I hope you can try it yourself & Please look for a better solution too which doesn't include storage structure like linked list if possible.
It will be better if you think this on your own - time consuming but worth gaining some experience.