42 lines
671 B
C++
42 lines
671 B
C++
/*
|
|
Nome: Mario
|
|
Cognome: Montanari
|
|
Classe: 3AIN
|
|
Data: 07/04/2025
|
|
|
|
File di Testo CSV
|
|
con l'uso di fscanf()
|
|
*/
|
|
|
|
#include <iostream>
|
|
|
|
#define SIZE_LINE 1000+1
|
|
|
|
using namespace std;
|
|
|
|
void apriFile(const char * nomeFile);
|
|
|
|
int main(void) {
|
|
apriFile("File CSV.txt");
|
|
|
|
return 0;
|
|
}
|
|
|
|
void apriFile(const char * nomeFile) {
|
|
FILE * fp = fopen(nomeFile, "rt");
|
|
|
|
if (fp != NULL) {
|
|
char nome[SIZE_LINE];
|
|
char cognome[SIZE_LINE];
|
|
int eta;
|
|
int i = 0;
|
|
|
|
while (fscanf(fp, "%[^ ] %[^;];%d", nome, cognome, &eta) == 3) {
|
|
cout << nome << " " << cognome << " " << eta;
|
|
}
|
|
|
|
fclose(fp);
|
|
} else {
|
|
perror("Error (source)");
|
|
}
|
|
} |