ifstream file ("../file.csv");
string test;
unsigned counter = 0;
while(counter<10){
getline(file,test,'"');
cout<<test<<endl;
counter++;
}
I am essentially trying to recreate this in c++ but without using the string class. I am trying to figure out a way to not use the string class and still use this same function. Any thoughts?
For some clarification I will be delimeting with a '"' and then I will be a comma after that, so there is a text surrounded in '"', and a conclusion that is seperated from the text by a comma.
This is my custom class
class customString {
char* myStr;
int length;
public:
customString();
customString(char enb);
customString(const customString& source);
customString(customString&& source);
~customString(){delete myStr;}
};
customString::customString(){
str = new char[1];
str[0] = '\0';
}
customString::customString(char enb) {
length = 1;
myStr= new char(enb);
}
customString::customString(const customString &source) {
length = source.length;
myStr = new char[length];
for (int i = 0; i < length; i++){
myStr[i]=source.myStr[i];
}
}
customString::customString(const char* val){
if(val!= nullptr){
int counter = 0;
while(val[counter]!='\0')counter++; //Find length of the char array
length = counter;
myStr = new char[counter];
for(int i =0;i<counter;i++){
myStr[i]=val[i];
}
}else{
length = 1;
myStr = new char[length];
myStr[0] = '\0';
}
}
customString::~customString(){
delete[] myStr;
}```