473,625 Members | 3,318 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

8 New Member
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 2227
spiralfire
8 New Member
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
5024
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 double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
0
2654
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 try and reinstall Office 2003 and see if that fixes this, but it is talking about the mscorlib.dll and that isn’t Office.
6
4738
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 appreciated. Thanks in advance
2
4433
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 then skip this file and move onto the next file (line). If file is there then move to a sirectory. Here is the code I have (Feel free to make corrections as needed. If possible make changes in red)
1
3379
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 but no success! This generally happens when I am browsing the tree in Object explorer in SQL 2005 Management Studio. I can be doing anything - like viewing databases, or viewing table list or viewing stored procedure list, etc.
15
5329
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 path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
5
1865
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/ Applications/Great Plains/ Applications/Great Plains/ Applications/Great Plains/ Applications/Great Plains/Servers/
0
1537
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 could not be found or loaded? File or assembly name Microsoft.VisualStudio.Tools.Applications.Runtime, or one of its dependencies, was not found.
1
3007
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 help me out in solving the issue. I'd like to get this solved so I can continue developing with Django using MySQL since that's what my web server uses as well. I'd hate to have to develop using a different database engine on my local...
0
8189
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8694
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7184
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6118
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.