Resource leak or false positive

I have a code like this: std::string getInfo(FILE *fp) { char buffer[30]; if (fread(buffer, 19, 1, fp) == 1) buffer[19] = ‘\0’; else buffer[0] = ‘\0′; return buffer; } I’m using cppcheck for static analysis and it spits a warning: error: Resource leak: fp [resourceLeak] return buffer; ^ The way I see it, since the… Read More Resource leak or false positive

How to properly read data from CSV file in C++

My input file userinfo.csv contains username and password in this format username,password shown below. frierodablerbyo,Rey4gLmhM pinkyandluluxo,7$J@XKu[ lifeincolorft,cmps9ufe spirginti8z,95tcvbku I want to store all the usernames and passwords in vector<string> usernames; vector<string> passwords; I’ve never used C++ for file handling, only python EDIT1 #include <bits/stdc++.h> using namespace std; int main() { fstream myfile; myfile.open("small.csv"); vector<string> data;… Read More How to properly read data from CSV file in C++