fstream

Read cells from Excel in C++?

徘徊边缘 提交于 2021-02-19 04:09:58
问题 I was wondering how you can read specific cells from an Excel spreadsheet, in C++. I understand we have to use the "fstream" library, but I don't know exactly how I could get those values from a certain cell, and print it on the screen. Any help would be appreciated, thanks! Carpetfizz 回答1: in linux you have this free: http://libxls.sourceforge.net/ in windows you have http://www.libxl.com/ which seems to cost money: Book* book = xlCreateBook(); if(book) { if(book->load(L"example.xls")) {

Read cells from Excel in C++?

烂漫一生 提交于 2021-02-19 04:08:11
问题 I was wondering how you can read specific cells from an Excel spreadsheet, in C++. I understand we have to use the "fstream" library, but I don't know exactly how I could get those values from a certain cell, and print it on the screen. Any help would be appreciated, thanks! Carpetfizz 回答1: in linux you have this free: http://libxls.sourceforge.net/ in windows you have http://www.libxl.com/ which seems to cost money: Book* book = xlCreateBook(); if(book) { if(book->load(L"example.xls")) {

Read cells from Excel in C++?

流过昼夜 提交于 2021-02-19 04:07:49
问题 I was wondering how you can read specific cells from an Excel spreadsheet, in C++. I understand we have to use the "fstream" library, but I don't know exactly how I could get those values from a certain cell, and print it on the screen. Any help would be appreciated, thanks! Carpetfizz 回答1: in linux you have this free: http://libxls.sourceforge.net/ in windows you have http://www.libxl.com/ which seems to cost money: Book* book = xlCreateBook(); if(book) { if(book->load(L"example.xls")) {

How to open input file, C++ on visual studio community 2015?

你说的曾经没有我的故事 提交于 2021-02-18 11:32:10
问题 Does anyone know why the file isn't opening? I also tried just putting "infile.txt" and placing it in the folder of the program and also the debug folder but the ways I used to check for open error both triggered meaning that it could not open. I know I can hard code the location but I don't want to. I heard you should do stringobj.c_str() but I don't know if that's accurate? #include "stdafx.h" #include <iostream> #include <string> #include <fstream> using namespace std; int main() {

Delete specific line from file

≯℡__Kan透↙ 提交于 2021-02-16 18:27:10
问题 I'm trying to delete a specific line by id from a file in C++ and here is my code: void deleteRow() { ifstream inDb("files/students.dat", ios::in); if(!inDb) { cerr << "File could no be opened!\n"; } cout << countRowsOfDb() << " records." << endl; Student *studentsArray[countRowsOfDb()]; int n = 0; while(inDb >> id >> name >> grade >> points >> type) { studentsArray[n] = new Student(id, name, grade, points, type); n++; } inDb.close(); for(int i = 0; i < countRowsOfDb(); i++) { cout <<

Delete specific line from file

[亡魂溺海] 提交于 2021-02-16 18:26:32
问题 I'm trying to delete a specific line by id from a file in C++ and here is my code: void deleteRow() { ifstream inDb("files/students.dat", ios::in); if(!inDb) { cerr << "File could no be opened!\n"; } cout << countRowsOfDb() << " records." << endl; Student *studentsArray[countRowsOfDb()]; int n = 0; while(inDb >> id >> name >> grade >> points >> type) { studentsArray[n] = new Student(id, name, grade, points, type); n++; } inDb.close(); for(int i = 0; i < countRowsOfDb(); i++) { cout <<

read from a file while another process is writing to it using std::fstream [duplicate]

余生颓废 提交于 2021-02-08 03:48:00
问题 This question already has answers here : How to read a growing text file in C++? (4 answers) Closed 6 years ago . I need to read from a file line by line, it's done by std::getline. The problem another process is appending data to it all the time, then I need to read the new lines. For example, the file contains 10 lines at first, my program read the 10 line, then my program should wait. A while later another process append 5 lines to the file, then my program read the 5 lines. I tried this

Reading a string from a file in C++

不问归期 提交于 2021-02-07 09:40:07
问题 I'm trying to store strings directly into a file to be read later in C++ (basically for the full scope I'm trying to store an object array with string variables in a file, and those string variables will be read through something like object[0].string). However, everytime I try to read the string variables the system gives me a jumbled up error. The following codes are a basic part of what I'm trying. #include <iostream> #include <fstream> using namespace std; /* //this is run first to create

Can't load correct information from file

瘦欲@ 提交于 2021-02-05 08:18:52
问题 the problem with this bit of code is that it is not reading the .txt file correctly, I have provided a image of the .txt file while also providing the current output it is giving me. Any help would be welcomed. #include <fstream> #include <iostream> using namespace std; const int MAX_CHARS = 10; const int MAX_STUDENTS = 1; class File { public: void openFile() { ifstream input_file("UserPass.txt", ios::binary); if (input_file.fail()) { cout << "Could not open file" << endl; } else { if (!input

Can't load correct information from file

混江龙づ霸主 提交于 2021-02-05 08:18:08
问题 the problem with this bit of code is that it is not reading the .txt file correctly, I have provided a image of the .txt file while also providing the current output it is giving me. Any help would be welcomed. #include <fstream> #include <iostream> using namespace std; const int MAX_CHARS = 10; const int MAX_STUDENTS = 1; class File { public: void openFile() { ifstream input_file("UserPass.txt", ios::binary); if (input_file.fail()) { cout << "Could not open file" << endl; } else { if (!input