|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
Weird character sequence at end of a few lines is messing up my c executables
I'm taking over code from the previous programmer and am running into problems with one of his c executables. Specifically, this script opens up a file and reads it in one line at a time (using fgets), then processes it. However in a few instances, instead of reading in one line it's reading in multiples (which it's not supposed to do).
When I open up the original text file in vi the offending lines have a ^@ sequence at the end. So for example there might be lines like Hello there ^@ How are you doing ^@ That's great. Although this is three lines, fgets is reading it as Hello there How are you doing That's great. Now the ^@ sequence is not a carat following by an @ sign. For example, the file is separated by form feeds (ascii value 12). When I look at it through vi, however, it shows up as ^L. This ^@ must represent a sequence similar to the form feed (again, it's not simply the same as typing ^@). So my questions are: 1. What is the ^@ sequence? If I knew, I could do a search and replace. 2. Is there any way that I can force c to treat it like a new line character? Thank you for any help that you can give. |
|
#2
|
||||
|
||||
|
fgets reads until it encounters a new line. You will have to convert the form feeds to new lines.
Last edited by Onslaught : January 29th, 2003 at 03:01 PM. |
|
#3
|
||||
|
||||
|
Actually, the situation is more like
Hello there ^@ How are you doing ^@ That's great. ^L The ^L is the actual form feed character, which is used to separate a record. I have no idea what the ^@ is, so don't even know how to search for (and thus replace) it. However, I rewrote the previous programmer's script in Perl. Perl simply disgarded those ^@ characters, so I at least got my project done. However, it would be interesting to know what exactly tha ^@ sequence is. In any event, thanks for the help. |
|
#4
|
||||
|
||||
|
You can always look at the file in hex mode and see what that particular sequence is.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Weird character sequence at end of a few lines is messing up my c executables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|