473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

newline at the end of file

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.
Jul 22 '05 #1
1 5417
On 19 Nov 2003 15:06:32 -0800, ae******@emich.edu (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
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: runningdog | last post by:
Hi, I would like to be able to embed a newline in a text string. Is there any convienent notation to do this TIA Steve
7
by: Alex Nordhus | last post by:
I am looking for a way to strip the blank line and the empty newline at the end of the text file. I can get the blank lines removed from the file but it always leaves the end line (which is blank)...
8
by: surendran.d | last post by:
hi, I am using gcc 3.4.4 for c++, i am getting the following warning if there is no new line at the EOF. Why this warning and i am not getting the warning in vc++ compiler. thanks, suri
3
by: utab | last post by:
Dear all, I have a text file in the form of 1 2 3 4 5 6 --------/--------/--------/--------/--------/--------/ (I just used / to better explain the...
1
by: utab | last post by:
Hi there I am trying to read from a file, I am trying to read certain fields,there are 6 fields in this file like --------/--------/--------/--------/--------/--------/ All fields are 8...
2
by: John Salerno | last post by:
If I read a string that contains a newline character(s) into a variable, then write that variable to a file, how can I retain those newline characters so that the string remains on one line rather...
11
by: rossum | last post by:
I want to declare a const multi-line string inside a method, and I am having some problems using Environment.NewLine. I started out with: class foo { public void PrintStuff() { const...
1
by: linq936 | last post by:
Hi, I read in many places that the string to be outputted by printf() must be ending with newline, for example, it should be printf("Hello World.\n"); instead of printf("Hello World.");
4
by: Florian Lindner | last post by:
Hello, I have a piece of code like that: for row in resultSet: logs += "/home/%s/%s/log/access.log \n" % (row, row) logs += "/home/%s/%s/log/error.log \n" % (row, row) # <-- Now I want to...
0
by: Peter Donis | last post by:
When running a doctest text file with doctest.testfile, I noticed that universal newline support did not appear to work when module_relative is False. My text file was saved on a Windows machine...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.