473,398 Members | 2,393 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,398 software developers and data experts.

Problem with file() and fgets()


Hi,

when reading lines from a text file using either of the functions file() or
fgets() all characters with ASCII codes greater than 127 get scrambled.

Using a hex editor I created a file containing a sequence of 128 bytes with
values from 128 up to 255.
After reading this file with file() or fgets() the string representing the
file content reads

196 197 199 201 209 214 220 225 224 226 228 227 229 231 233 232 234 235 237
236 238 239 241 243 242 244 246 245 250 249 251 252 221 176 162 163 167 128
182 223 174 169 129 180 168 130 198 216 131 177 190 132 165 181 143 133 189
188 134 170 186 135 230 248 191 161 172 136 159 137 144 171 187 138 160 192
195 213 145 166 173 139 179 178 140 185 247 215 255 141 142 164 208 240 222
254 253 183 146 147 148 194 202 193 203 200 205 206 207 204 211 212 149 210
218 219 217 158 150 151 175 152 153 154 184 155 156 157

instead of the desired sequence 128 to 255.

Characters with ASCII-Codes lower than 128 are read correctly.

Thanks for any help.

Jul 16 '05 #1
0 1716

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

Similar topics

7
by: Rafael | last post by:
Hello Everyone, I need some major help with this code I have for a file viewer. I need it to stop at the 24th line. What Syntax do I need for this to happen? Here is the code.... #include...
4
by: Karthick S. | last post by:
Hi, fgets returns NULL on error and the first argument on success. I want to open a file and read it using fgets. This is returning NULL, when the file is empty. Is there anyway to circumvent...
7
by: Emerson | last post by:
Hi all: my problem is in the comments of the code . would u please give me some clue what 's the problem? what u in advance. /*******************************/ #include "stdio.h" #include...
32
by: Clunixchit | last post by:
How can i read lines of a file and place each line read in an array? for exemple; array=line1 array=line2 ...
2
by: Phil396 | last post by:
I have a Windows service that use a FileSystemWatcher to scan incoming html for information. The process worked fine in a Windows Application and it also works fine in a Windows Service except...
4
by: jimdscudder | last post by:
I am using a file watcher to watch for files changing. My problem is: the string file info returned is all LOWER CASE. Below is the important part of the code? Any suggestions? using...
5
by: Trond Valen | last post by:
Hi! Anyone who knows what the reason might be? fgets is supposed to return null when reading EOF. I have a test for this, so my while loop should exit, but it doesn't ... Trond
34
by: Zulander | last post by:
Hi, have a problem with comparing text in my function for some reason my code get hang at fgets. i am uploading this code in an IC, but i have isolated the problem to fgets(SettingInfo); could...
3
by: Hamayun Khan | last post by:
I have Two asp pages addfiles.asp insert.asp addfiles.asp is used to browse the files which i want to upload to server. in IE both the pages run and the files uploads ok. There is...
0
by: fantasticamir | last post by:
I have a simple program using a couple of classes and it compiled successfully but while it is linking I have the following problem: g++ -Wall -lcu -lglu ACL2MDD.o Link.o Rule.o reachability.o ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.