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

Cannot open the file in binary mode

151 100+
Hi ,
I am trying to open a file in binary to write. But I am getting the message
"could not open the file".

fstream outCredit( "credit.dat", ios::in | ios::out | ios::binary );
if ( !outCredit )
{
cerr << "File could not be opened." << endl;
exit( 1 );
}

i am running on gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3).

What is the reason for this pblm.

Regards
Manish
Mar 27 '09 #1
5 3841
Man4ish
151 100+
@Man4ish
Sorry message is File could not be opened.Also I want to know if we convert file into binary then, will it take more time to read ?
Mar 27 '09 #2
weaknessforcats
9,208 Expert Mod 8TB
credit.dat is obviously not in your PWD (present working directory).

Usually the PWD is the folder with your project files.

If it is elsewhere, then specify the complete path.
Mar 27 '09 #3
Man4ish
151 100+
I am using Eclipse CDT and keeping program and input in the same folder(project), still there is an error. May i know is it possible for linux not to read the binary file?
Mar 27 '09 #4
weaknessforcats
9,208 Expert Mod 8TB
linux can read a binary file. That's not your problem. The problem you reported is that the file cannot be found. Have you tried using a complete path? Also, have you set your PWD?

I know your code to open the file works because I compiled it using Visual Studio.NET 2008 and ran it in the debugger. Your file open fine when the file was in the same folder as the project files.
Mar 27 '09 #5
Man4ish
151 100+
@weaknessforcats
Thanks, for helping me. I changed the path to full path, now it wi working fine.

Thanks
Manish
Mar 30 '09 #6

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

Similar topics

1
by: Eric Pederson | last post by:
WryPyY's- I've come across this file operation in others' code and have not seen any documentation for it: the use of "t" in the mode of file opening, such as: f1=open(somefile, 'at')...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
22
by: Smutny30 | last post by:
Hello, I am preparing a database that will store 10 n * GBs - 100 n * GBs of data. I calculated to have 1,2 GB of bufferpools. I run the DB2 v. 8.2.1 alone on 4 GB box. I obtain : ...
49
by: Sam | last post by:
Hi all, Is there a function in the standard library that can get the size of a file? Thank you very much. Sam.
35
by: munish.nr | last post by:
Hi All, I want to know the size of file (txt,img or any other file). i knoe only file name. how i can acheive this. does anybody is having idea about that. plz help. rgrds, Munish Nayyar
4
by: Bishman | last post by:
Hi, Can someone suggest the best technique / method of opening a Word ( or any other ) Document from an SQL BLOB ? I have the process of saving and retrieveing the file from an SQL Binary...
11
by: jean-jeanot | last post by:
I can access to a file with the command: file_obj = open ( " D:\My documents\Textfile.txt",'r') When I now try to read a file with the following command: file_obj = open ("D:\My...
2
by: tubby | last post by:
Does a py script written to open and read binary files on Windows affect files on a Linux or Mac machine in a negative way? My concern is portability and safety. I want scripts written within...
9
by: Hatzigiannakis Nikos | last post by:
I have written the following code in DEV C++ but the produced file is a normal text file (you can type it in command line). I was expecting that the numeric values would have written in their...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.