•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 425,928 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,655 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1785 | Replies: 3
![]() |
•
•
Join Date: Nov 2006
Posts: 10
Reputation:
Rep Power: 2
Solved Threads: 0
Hi All!!
I am relatively new to C++ programming so please forgive me if my question is very basic or silly. I am trying to read files in C++. It opens text based files properly but doesnt open csv files , though I am saving them in the same directory. It doesnt open the file even if we save the csv file as txt file. Also my program is opening the files that are being saved in the current directory only. If we save the same file in other directory & specify the whole path in program then also it fails to open that file. I dont know wht the problem is. Could you people please help me with this.
I am relatively new to C++ programming so please forgive me if my question is very basic or silly. I am trying to read files in C++. It opens text based files properly but doesnt open csv files , though I am saving them in the same directory. It doesnt open the file even if we save the csv file as txt file. Also my program is opening the files that are being saved in the current directory only. If we save the same file in other directory & specify the whole path in program then also it fails to open that file. I dont know wht the problem is. Could you people please help me with this.
•
•
Join Date: Jun 2005
Location: Tokyo, Japan
Posts: 1,481
Reputation:
Rep Power: 8
Solved Threads: 102
It is a bit strange that you can open text files but not csv files. They are essentially both text files, and only the file extensions are different. So give us the code that you are using to open the files. Maybe we can find something more by looking at the code. If you are using file paths, you should use double backslashes like "C:\\temp\\temp.txt".
バルサミコ酢やっぱいらへんで
•
•
Join Date: Nov 2006
Posts: 10
Reputation:
Rep Power: 2
Solved Threads: 0
Hi!! heres the code I am using:-
When compiled & run, this program opens txt file but is unable to open a csv file.
Please help.
const int MAX=100;
char str[MAX];
ifstream infile;
infile.open("abc.csv");
// I have also tried giving the full path here
if(!infile)
cout<<"unable to open file";
{
infile.getline(str,MAX);
cout<<endl<<str;
} When compiled & run, this program opens txt file but is unable to open a csv file.
Please help.
Last edited by WaltP : Feb 5th, 2007 at 3:07 pm. Reason: Corrected CODE tags -- use the Preview button
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- dat,txt file and csv file???? (C++)
- insert csv file into mysql through php (PHP)
- CSV file (C)
- Remove quotation marks from a CSV file (C#)
Other Threads in the C++ Forum
- Previous Thread: error C2447: missing function header(old-style formal list?)
- Next Thread: help with an assignement please



Linear Mode