newline at the end of file



 DEVELOP > c-Plus-Plus > newline at the end of file

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "av"
Date: 19 Nov 2003 05:06:32 PM
Object: newline at the end of file
hi all,
i am trying to transfer a text file from client to server. say, my
text file on the client side is named like this "afile.txt":
on the server side, am storing it by different name i.e "bfile.txt"
"afile.txt"
1 djfldjf"\n"
2 dslfjlsdjf"\n"
3 shfdjhfsj"\n"
4 djfldjf"\n"
5 dslfjlsdjf"\n"
6 shfdjhfsj"\n"
the above file contains 6 lines 58 characters (i.e 52 characters and 6
new-lines).
the client reads the file character by character. puts it into an
array. when it reads the last character i.e "\n" in the 6th line, it
goes to the next line i.e 7th line...checks if there are any
characters and then comes to an conclusion that the end-of-file has
occured. till now no problem.
on the server side, it gets till the last before character, i.e "j" in
the 6th line. then it gets the "new line character". now what is
happening is, "the server is expecting for more lines". so when i open
the "bfile.txt", all the above lines are copied and the error that i
get is "Incomplete Last Line" and some junk value like " ^C ^M".
i realize the newline is causing me problems. but how to overcome it.
how to let know the server that its the end of the message.
this is done in unix with c++.
kindly let me know.
thank u.
av.
.

User: "Jack Klein"

Title: Re: newline at the end of file 19 Nov 2003 08:32:11 PM
On 19 Nov 2003 15:06:32 -0800,
(av) wrote in
comp.lang.c++:

hi all,

i am trying to transfer a text file from client to server. say, my
text file on the client side is named like this "afile.txt":
on the server side, am storing it by different name i.e "bfile.txt"

"afile.txt"

1 djfldjf"\n"
2 dslfjlsdjf"\n"
3 shfdjhfsj"\n"
4 djfldjf"\n"
5 dslfjlsdjf"\n"
6 shfdjhfsj"\n"

the above file contains 6 lines 58 characters (i.e 52 characters and 6
new-lines).

the client reads the file character by character. puts it into an
array. when it reads the last character i.e "\n" in the 6th line, it
goes to the next line i.e 7th line...checks if there are any
characters and then comes to an conclusion that the end-of-file has
occured. till now no problem.

on the server side, it gets till the last before character, i.e "j" in
the 6th line. then it gets the "new line character". now what is
happening is, "the server is expecting for more lines". so when i open
the "bfile.txt", all the above lines are copied and the error that i
get is "Incomplete Last Line" and some junk value like " ^C ^M".

i realize the newline is causing me problems. but how to overcome it.
how to let know the server that its the end of the message.

this is done in unix with c++.

kindly let me know.

thank u.
av.

Why do you think this is a C++ language issue? Read the documentation
for the server software to find out what it expects for an end of file
indicator.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
.


  Page 1 of 1

1

 


Related Articles
Pointing one past the end element
Which destructor is called in which sequence at the end of the main program?
How do I stop reading input at the end of a line?
Dereferencing past-the-end iterators
To delete few lines and add few lines at the end of a text file using c program
How Do We Avoid the Extra Empty Line at the End of the Output File?
Re: Help!!! Help!!! Added a new project, compiles OK, at the end,no .a file
Incrementing a pointer to a one-past-the-end value?
How to test if an iterator is at the end of the container
how to find the two end points in a line ...
The end of my streambuf road...
how to add at the end of the linked list
Basic swap trick for stl containers!!!! (very interesting, READ till the END!)
Forward iterators and past-the-end iterator
Why is ; used at the end of class definition.
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER