Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int liczR(char name[]){
- ifstream p;
- string tmp;
- int i=0;
- p.open(name);
- while(p.good())
- {
- getline(p,tmp);
- i++;
- }
- p.close();
- return i-1;
- }
- int liczC(char name[]){
- ifstream p;
- char c;
- int i=0,tmp;
- p.open(name);
- while(p.good())
- {
- p >> tmp;
- p.get(c);
- i++;
- if(c=='\n')break;
- }
- p.close();
- return i;
- }
- int** generuj(int R, int C){
- int **tmp;
- tmp = new int *[R];
- for (int i = 0; i < R; i++)
- tmp[i] = new int [C];
- return tmp;
- }
- int** czytaj(char name[], int *R, int *C){
- int **tmp;
- ifstream p;
- *R=liczR(name);
- *C=liczC(name);
- tmp=generuj(*R,*C);
- p.open(name);
- for(int i=0; i<*R;i++){
- for(int j=0; j<*C; j++){
- p>>tmp[i][j];
- p.get();
- }
- }
- p.close();
- return tmp;
- }
- //main
- int **tab1, R,C;
- char fileO[]={"linia.csv"};
- tab1 = czytaj(fileO,&R,&C);
- for(int i=0; i<R; i++){
- for(int j=0; j<C; j++){
- cout << tab1[i][j]<<";";
- }
- cout<<endl;
- }
Add Comment
Please, Sign In to add comment