hi, i'm workin on a lab for an intro to computer science class which deals with c++... one of the ten parts of it says the following
Read about the getline command for fetching an entire line from a input stream. Then make a text file of mixed words and numbers separated by commas. Write a function that takes an open stream as a parameter reads one line, and then prints each word or number from the line on a separate line (do not print any commas). Read five lines.
now i know how to use the getline command but i have no idea as to write the function that takes an open stream as a paramater ... here is my code from what i think i understood from the problem
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
int main(){
ofstream fileWrittenInto;
fileWrittenInto.open("fileUsedHere.csv");
if(fileWrittenInto.fail()){
cout<<"error opening fileUsedHere.csv"<<endl;
exit(1);
}//if open fileWrittenInto
char c[20];
fileWrittenInto << cin.getline(c,20);
cout<<c<<"\n"<<endl;
fileWrittenInto.close();
/**
ifstream someFileIn;
someFileIn.open("lab09.2.cc.csv");
if(someFileIn.fail()){
cout<< "error opening the file requested\n";
exit(1);
}
cout<<
someFileIn.getline(c,20);
**/
return 0;
}//main
void somefunction(char * bs){//bs=open stream
while(!bs.eof()){
getline(bs,x,',');
cout<<x<<endl;
}