C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 24th, 2004, 08:26 PM
TufGi TufGi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 2 TufGi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ifstream/ofstream question

ok, this is the order of the process i want to happen :

1. open file w/ data already present in it (data will be a simple '500')
2. read that data (500) and convert to INT varaible (file_data = int variable)
3. add/subtract that data w/ new data (file_data = file_data +- new_data)
4. save the file w/ the total of old data +- new data
5. close that file w/ the new data

6. in a week, i would do this again, but w/ the updated file_data from the previous week

here is my code, plz correct or if you have a better way of coding, please explain ...

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

int total1[7];
int add1;

ifstream member_total ("total_amt.txt"); // 1

member_total = total1[7]; //2

cout << "Amount in TuffLess's account : '" << total1[7] << "'" << endl;
cout << "Amount to 'ADD' to TuffLess's bank account?: ";
cin >> add1;

member_total = total1[7] + add1; //3

member_total << total1[7]; //4 binary '>>' : no operator defined which takes a right-hand operand of type 'int [7]' (or there is no acceptable conversion) -- HOW DO I FIX THIS ?

//member_total.close(); //5 THIS CAUSES THE PROGEE TO CRASH AND DOES NOT SAVE NEW DATA IN .txt FILE

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

-when i goto read the '1st step' and cout << member_total; 'or' cout << total1; ... i get a memory addy or a '0' respectivly
-i cant get the NEW total to save in the file for the next week
-when i go to close the txt file, it crashes


id appreiciate any help you could provide, thanx much

tuffy

Reply With Quote
  #2  
Old September 25th, 2004, 10:18 AM
The Phantom The Phantom is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: In the Dark City
Posts: 46 The Phantom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to The Phantom
So i guess you are saying that it is correct and it works right?

If it isn't whats the error?

Reply With Quote
  #3  
Old September 25th, 2004, 11:16 AM
TufGi TufGi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 2 TufGi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
-when i goto read the '1st step' and cout << member_total; 'or' cout << total1; ... i get a memory addy or a '0' respectivly instead of500
-i cant get the NEW total to save in the file for the next week
-when i go to close the txt file, it crashes

those are the problems
and this is one of the errors :

binary '>>' : no operator defined which takes a right-hand operand of type 'int [7]' (or there is no acceptable conversion)


Quote:
Originally Posted by The Phantom
So i guess you are saying that it is correct and it works right?

If it isn't whats the error?

its all above phantom, i just re-posted it for you

Reply With Quote
  #4  
Old September 25th, 2004, 12:03 PM
The Phantom The Phantom is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: In the Dark City
Posts: 46 The Phantom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to The Phantom
It seems like a good problem to be fixed..

I am thinking that use should use "Strings"

Code:
   
member_total << total1[7]; 

i dont think you need it because you have,
Code:
 member_total = total1[7]; 

Code:
//member_total.close(); //5 THIS CAUSES THE PROGEE TO CRASH AND DOES NOT SAVE NEW DATA IN .txt FILE


this is caused by

Code:
member_total << total1[7];

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > ifstream/ofstream question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT