newline at the end of file

A

av

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.
 
J

Jack Klein

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top