Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > newline at the end of file

Reply
Thread Tools

newline at the end of file

 
 
av
Guest
Posts: n/a
 
      11-19-2003
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.
 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      11-20-2003
On 19 Nov 2003 15:06:32 -0800, http://www.velocityreviews.com/forums/(E-Mail Removed) (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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is a blank at the end of a C file a better style than a newline atthe end of the file or is it better to place none? Jimmy C Programming 13 09-21-2011 12:17 AM
Is a blank at the end of a C file a better style than a newline atthe end of the file or is it better to place none? Jimmy C Programming 3 09-09-2011 10:36 PM
remove NEWLINE at the end of the file gk Java 9 04-11-2006 10:57 AM
Warning: no newline at end of file surendran.d@gmail.com C++ 8 01-12-2006 05:32 PM
warning: no newline at end of file padam.singh@gmail.com C Programming 2 06-13-2005 09:59 AM



Advertisments