Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: main.cpp
- * Author: samoel
- *
- * Created on 1 de septiembre de 2015, 10:52 PM
- */
- #include <cstdlib>
- #include <cstdio>
- #include <iostream>
- #include <cstring>
- #include <fstream>
- using namespace std;
- int main(int argc, char** argv) {
- ifstream input;
- input.open("C://temp//data.txt",ios::in);
- if(!input){
- cerr << "Error en abrir el archivo\n";
- }
- string matriz[20][20];
- string linea;
- int i= 0,j =0;
- int prim = 1, tamJ = 0;
- char * parte ;
- while(!input.eof()){
- getline(input,linea);
- cout << linea << "\n";
- char* line = new char[linea.length() +1 ];
- strcpy(line,linea.c_str());
- parte = strtok(line,",");
- while(parte != NULL){
- string str(parte);
- matriz[i][j] = str;
- j++;
- parte = strtok(NULL,",");
- }
- if (prim){prim = 0; tamJ = j;}
- i++; j = 0;
- }
- for(int w = 0; w < i; w++){
- for(int x = 0; x < tamJ;x++){
- cout << matriz[w][x] << " ";
- }
- cout << endl;
- }
- printf("todo ocs");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement