| | |
C code for LINE SEPARATING
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2008
Posts: 5
Reputation:
Solved Threads: 0
hello..
I m designing a STATISTICAL SUMMARIZER in C..
This software will create the summary of a text file submitted by
the user..
The first step is to separate line in the text file..
I hav almost completed this step..
but there are some limitations..
Suppose if text file hav this input..e.g
Hello! This is MAYANK. I am a Student of "nitk."
Working on a project.
then how i will separate these lines??
can u provide me with a code of line separation..
I m designing a STATISTICAL SUMMARIZER in C..
This software will create the summary of a text file submitted by
the user..
The first step is to separate line in the text file..
I hav almost completed this step..
but there are some limitations..
Suppose if text file hav this input..e.g
Hello! This is MAYANK. I am a Student of "nitk."
Working on a project.
then how i will separate these lines??
can u provide me with a code of line separation..
Have a look at a function calle3d fgets which is defined under stdio.h library. This function will do what excatly you want. It read a line of text from the text file until it EOF which then return NULL. The sample usage of that function can be found bellow
ssharish
C Syntax (Toggle Plain Text)
FILE *fp; char buffer[BUFSIZ]; if( ( fp = fopen( <filename>, "r") ) != NULL ) { while( fgets( buffer, BUFSIZ, fp) != NULL ) printf( "%s", buffer ); /* You could backup this buffer by copying it on to a different char array */ }
ssharish
the function that would be helpful for you here, i think, is STRTOK
in the string.h library.
it will separate any text into "tokens" based on a set of "delimiters"
your "tokens" will be individual lines, and your set of "delimiters" will simply be the newline character '\n'
once you have your individual lines you can insert anything you want in between them, and then rewrite them to a buffer or another text file as you desire.
http://www.cplusplus.com/reference/c...ng/strtok.html
in the string.h library.
it will separate any text into "tokens" based on a set of "delimiters"
your "tokens" will be individual lines, and your set of "delimiters" will simply be the newline character '\n'
once you have your individual lines you can insert anything you want in between them, and then rewrite them to a buffer or another text file as you desire.
http://www.cplusplus.com/reference/c...ng/strtok.html
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Jun 2008
Posts: 5
Reputation:
Solved Threads: 0
thnks all of u...
bt i m nt looking for separating the sentences..
for eg.
input
Hello! This is MAYANK. I am a Student of "nitk."
Working on a project.
output:
Hello! This is MAYANK.
I am a Student of "nitk."
Working on a project.
sorry for giving the heading as line separation
it would be rather sentence separation..
i hav started new thread with this name..
do reply to that thrad..
thnku...
bt i m nt looking for separating the sentences..
for eg.
input
Hello! This is MAYANK. I am a Student of "nitk."
Working on a project.
output:
Hello! This is MAYANK.
I am a Student of "nitk."
Working on a project.
sorry for giving the heading as line separation
it would be rather sentence separation..
i hav started new thread with this name..
do reply to that thrad..
thnku...
![]() |
Similar Threads
- How to print to file (Perl)
- Help on C++ Final Exam !!! (C++)
- separating line by line from textbox with textmode=multiline (ASP.NET)
- ASP Code Works on Local 127.0.0.1 but Not on ISP's Server (ASP)
- CSV file (C)
- Scanning an inputted array of words, and separating each word into a new array? (C)
- Trouble with printing to a file (C)
- get posted form data in python (Python)
Other Threads in the C Forum
- Previous Thread: Reversing doubly linked list?
- Next Thread: Sentence separation..
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays asterisks binarysearch calculate changingto char character cm command copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fgets file fork forloop framework function functions givemetehcodez grade graphics gtkwinlinux hacking histogram homework include incrementoperators input intmain() iso kernel keyboard km lazy license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number oddnumber odf opensource overwrite owf pdf performance pointer posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket socketprograming spoonfeeding standard string student systemcall testing threads turboc unix user variable wab whythiscodecausesegmentationfault windowsapi





