Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 File I/O
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
The_$hit




PostPosted: Wed Jul 27, 2005 12:43 pm   Post subject: File I/O

My Program has created a file That is called Stock.txt And when i run the program once it puts all of the appropriate data to the file. but the next time i run the program it does not append the file but instead concates it. Please Help Me. I would sumbit thhe source code but it is all jumbled up with Carbon code also.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Wed Jul 27, 2005 12:53 pm   Post subject: (No subject)

In programming parlance, "append" and concatenate" generally mean the exact same thing. What's the actual problem?

Did it overwrite the contents of the file, rather than appending the new output to the end of the existing file?

If so, you need to open the output file for appending.

c++:
std::ofstream outputFile("Stock.txt", ios::app);


Also, why in the name of everything unholy are you messing with Carbon rather than Cocoa? For that matter, why are you dealing with GUIs at all when you're still asking questions about something as fundamental as file IO?
[Gandalf]




PostPosted: Wed Jul 27, 2005 4:01 pm   Post subject: (No subject)

wtd wrote:
Also, why in the name of everything unholy are you messing with Carbon rather than Cocoa?

What are Carbon and Cocoa? Are they GUI frameworks for C++?

Also, I saw some of your posts yesterday while searching around the ubuntu linux forums Smile.
The_$hit




PostPosted: Wed Jul 27, 2005 4:37 pm   Post subject: (No subject)

I have the included line. and sry i meant to say truncate instead of concate. But it deletes what was previosly stored in the file and overwrites it with new data. The Reason Why i am learning Carbon is because i am making an accounting application for my friend who is running Mac OS 9.2.
CoCoa runs only on OS X.

The function that i Managed to seperate from the rest of the code is:

code:

void WriteItem( Item &item)
{
std::ofstream out1("Stock.txt",std::ios::app);
if (!out1)
std::cout << "Broken!WriteItem()2"<<std::endl;
else
std::cout <<"Working!";
out1<<item.getName();
out1<<item.getDate();
out1<<item.getCost();
out1<<item.getAttribute();
out1.close();
}
wtd




PostPosted: Wed Jul 27, 2005 5:56 pm   Post subject: (No subject)

[Gandalf] wrote:
wtd wrote:
Also, why in the name of everything unholy are you messing with Carbon rather than Cocoa?

What are Carbon and Cocoa? Are they GUI frameworks for C++?


GUI (and other things related) frameworks for Mac OS X (and Mac OS 9.x for Carbon).

Carbon is primarily a C++ framework, and Cocoa primarily an Objective-C framework.
wtd




PostPosted: Wed Jul 27, 2005 5:56 pm   Post subject: (No subject)

The_$hit wrote:
i am making an accounting application for my friend who is running Mac OS 9.2.


Ah. Good luck.
The_$hit




PostPosted: Fri Jul 29, 2005 4:38 pm   Post subject: (No subject)

The Carbon Code is almost complete but the c++ File I/0 is what i am stuck on.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: