473,386 Members | 1,819 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,386 software developers and data experts.

Error while reading text file using VisualStudio. (duplicate lines)

I'm writing a parser, and im totally confused. Its apparently correct, but something is happening:

I do a fread command to a char array of the entire file (it isn't big), this is the file:

Expand|Select|Wrap|Line Numbers
  1. sphere
  2. {
  3.     center <-3,0,0>
  4.       radius 2
  5. }
  6. light
  7. {
  8.     direction <1, 1, 1>
  9.     color rgb(1,1,1)
  10. }
  11. camera
  12. {
  13.     parallel
  14.     position <1,0,0>
  15.     to <0,0,0>
  16.     up <0,1,0>
  17. }
  18. settings
  19. {
  20.      image_width 800
  21.      image_height 600
  22.      min_weight 1
  23.      max_recursion_level 1
  24. }
  25.  
but the buffer on the debug mode shows this:

Expand|Select|Wrap|Line Numbers
  1. sphere
  2. {
  3.     center <-3,0,0>
  4.       radius 2
  5. }
  6. light
  7. {
  8.     direction <1, 1, 1>
  9.     color rgb(1,1,1)
  10. }
  11. camera
  12. {
  13.     parallel
  14.     position <1,0,0>
  15.     to <0,0,0>
  16.     up <0,1,0>
  17. }
  18. settings
  19. {
  20.      image_width 800
  21.      image_height 600
  22.      min_weight 1
  23.      max_recursion_level 1
  24. }
  25. max_recursion_level 1
  26. }
  27.  
it is repeating the two last lines, and the parser fails because it's waiting for an EOF or other simbol..

probably it isn't on the fread sentence, but here it is:

Expand|Select|Wrap|Line Numbers
  1. fread(bufferdata, 1, 100000, fileIn);
  2.     buffer = bufferdata;
  3.  
bufferdata size is 10.000

What could be happening?


Thanks.
Dec 8 '09 #1
1 2217
Nevermind, after almost 9 searches on google i found the answer..

fread won't append /0 to the end of the buffer it read, so i put it manually there, using the fread return value and it's working fine.


edit:
if any mod want to delete this one, you can do it. Thanks.
Dec 8 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
0
by: Don Stevic | last post by:
I am running VS2005 and using VSTO for Word. I keep getting this error saying that there is no source code available for this location when I try and run this application. I am going to...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
2
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist...
1
by: SQLJunkie | last post by:
Hi, I have installed SQL 2005 RTM on a new server and I keep getting this error (described below) quite frequently. Was wondering if anyone has a clue on what's happening here. I tried googling...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
5
by: soup_nazi | last post by:
I want to remove duplicate entries within a text file. So if I had this within a text file... Applications/Diabetic Registry/ Applications/Diabetic Registry/ Applications/Diabetic Registry/...
0
by: jason_cuteboy | last post by:
Hi all, Completely new to Vb.net and trying to create a simple VB Office Excel application/spreadsheet. When I built the project, and excel opens up an error comes up.... Customization assembly...
1
by: Steve Ametjan | last post by:
I've been trying to get MySQL-python to install on Leopard for the past couple of days, and I keep running into relatively the same error. I'm hoping that someone on this list will be able to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.