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

working code stops working

This has been quite frustrating. At the end of my program, I checksum the file I'm working on. Yesterday, the code worked. I made a few unrelated changes and now the code just doesn't even do what it is supposed to.

newFile is an fstream object opened under binary.

##############################################

newFile.seekp(0, ios::end); //without this it
newFile.put(0); // won't write

// checksum
newFile.seekg(55, ios::beg);
unsigned short nCheckSum = 0;
unsigned char chCurrentCheck;
for (int iii = 0; iii < nThisFileSize + 19; iii++)
{
newFile.read((char*)(&chCurrentCheck), 1);
nCheckSum += chCurrentCheck;
cout << chCurrentCheck;
}
newFile.seekp(-1, ios::end); //actually supposed to be 0
newFile.write((char*)(&nCheckSum), 2);
cout << nCheckSum << endl;

##################################################

This code used to work, but stopped for no reason. And if I put the write before the checksum, it works. Also I believe the checksum is wrong, that's what the trouble is.

Any ideas?
Aug 13 '09 #1
0 1112

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

Similar topics

0
by: sam | last post by:
I am running win2k3, iis6, access db's, for a web app. The problem is that asp stops working randomly. No errors in IIS log, no errors in even viewer. It just stops serving asp. Restarting IIS...
1
by: Steve | last post by:
I have almost got this no touch deployment of WinForms working Except... 1) Occasionally the launching of the application stops and I get the IE Message "The page cannot be found". If I restart...
2
by: Martin Hjärtmyr | last post by:
I have a program that uses Hotkeys! And they works just fine! I use this hotkeylib:...
4
by: Qingdong Z. | last post by:
I have a VS.NET windows application which use drag-drop feather. It works fine when application start, but stops working after application run one or two days. The application is related to Video...
0
by: Nikhil Patel | last post by:
Hi all, I installed an asp.net application on a client's machine on Friday. It uses a Sql Server database as backend. Database server and Web server are on different machines but same domain. The...
2
by: Nikhil Patel | last post by:
Hi all, I installed an asp.net application on a client's machine on Friday. It uses a Sql Server database as backend. Database server and Web server are on different machines but same domain. The...
6
by: Nx | last post by:
i've got it all working nicely in firefox, but whenever i test it in IE none of the onclick events are triggered. i'm using an xsl to transform an rss feed into a photogallery. when i try to...
3
by: Workaholic | last post by:
Hi, I have a problem that I have now seen on two different servers. I have a VB.Net application that is installed on the servers. It works fine on both servers. If I make a change to the...
4
by: Sigilaea | last post by:
My previous post got squashed because m post is too long. Sorry for that: I have an AJAX page with a CSS menu at the top. My problem is the hover functionality stops working after someone clicks...
1
by: rcldesign | last post by:
I have a web service (.NET 3.5) that (should take) a long time to finish what it's doing (in the neighborhood of 20 minutes). I am calling this webservice asynchronously from an ASP .NET page -...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.