zergling
13-01-2008, 22:25
Ciao a tutti,
Apro questo post perche dovrei leggere info da un file e mettere questi dati in un array.
Come potrei fare?
#include <iostream>
#include <fstream>
using namespace std;
struct Holiday
{
string holName;
string holAbbr;
int holDate; //day of the month 1-31
};
class Month
{
private:
string monthName;
int daysinMonth;
int startDow; //Sunday=1, Monday=2 etc. Saturday=7
int numHols;
Holiday events[10]; //Array on struct Holiday
public:
int showCalendar();
};
int main()
{
Month year[12]; // Object year of the class Month
return 0;
}
file da dove devo prendere i dati month.txt
January,31,3,3
February,29,6,2
March,31,7,1
April,30,3,4
May,31,5,1
June,30,1,3
July,31,3,5
August,31,6,4
September,30,2,3
October,31,4,2
November,30,7,3
December,31,2,4
la prima cifra si riferisce tot giorni, la seconda cifra si riferisce alla scazio che devo lasciare (esempio calendario del PC), e l'ultima cifra si riferisce al numero di festivita
Apro questo post perche dovrei leggere info da un file e mettere questi dati in un array.
Come potrei fare?
#include <iostream>
#include <fstream>
using namespace std;
struct Holiday
{
string holName;
string holAbbr;
int holDate; //day of the month 1-31
};
class Month
{
private:
string monthName;
int daysinMonth;
int startDow; //Sunday=1, Monday=2 etc. Saturday=7
int numHols;
Holiday events[10]; //Array on struct Holiday
public:
int showCalendar();
};
int main()
{
Month year[12]; // Object year of the class Month
return 0;
}
file da dove devo prendere i dati month.txt
January,31,3,3
February,29,6,2
March,31,7,1
April,30,3,4
May,31,5,1
June,30,1,3
July,31,3,5
August,31,6,4
September,30,2,3
October,31,4,2
November,30,7,3
December,31,2,4
la prima cifra si riferisce tot giorni, la seconda cifra si riferisce alla scazio che devo lasciare (esempio calendario del PC), e l'ultima cifra si riferisce al numero di festivita