I have no idea how to use the strftime() to display the time and date - we don't use pointers yet.
Thanks in advance again
Last question i promise
This post has been edited by Ollie9: 08 October 2010 - 08:42 PM




Posted 08 October 2010 - 08:40 PM
This post has been edited by Ollie9: 08 October 2010 - 08:42 PM
Posted 08 October 2010 - 08:46 PM
Posted 08 October 2010 - 09:35 PM
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <fstream>
using namespace std;
struct RecordStruct
{
char timedate[80];
};
int main(void)
{
fstream File;
fstream Open;
RecordStruct records;
time_t rawtime;
struct tm * timeinfo;
File.open( "C:\\test", ios::binary | ios::out );
Open.open( "C:\\test", ios::binary | ios::out );
time ( &rawtime );
timeinfo = localtime ( &rawtime );
strftime (records.timedate, 80, "%d/%m/%y %H:%M:%S" ,timeinfo);
puts (records.timedate);
File.write(( const char* ) &records, sizeof( records ));
File.close();
cout << "Date and time" << endl;
while ( !Open.eof())
{
cout << records.timedate;
Open.read(( char* ) &records, sizeof( records ));
}
Open.close();
return 0;
}
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <fstream>
using namespace std;
struct RecordStruct
{
char timedate[80];
};
void print();
int main(void)
{
fstream File;
RecordStruct records;
time_t rawtime;
struct tm * timeinfo;
File.open( "C:\\test", ios::binary | ios::out );
time ( &rawtime );
timeinfo = localtime ( &rawtime );
strftime (records.timedate, 80, "%d/%m/%y %H:%M:%S" ,timeinfo);
puts (records.timedate);
File.write(( const char* ) &records, sizeof( records ));
print();
return 0;
}
void print()
{
fstream Open;
RecordStruct records;
Open.open( "C:\\test", ios::binary | ios::out );
cout << "Date and time" << endl;
while ( !Open.eof())
{
cout << records.timedate;
Open.read(( char* ) &records, sizeof( records ));
}
}
This post has been edited by Ollie9: 08 October 2010 - 09:39 PM
Posted 08 October 2010 - 09:49 PM
#include <time.h>
#include <stdio.h>
int main()
{
char tmpbuf[128];
time_t ltime;
struct tm *today;
time( <ime );
today = localtime( <ime );
/* Use strftime to build a customized time string. */
strftime( tmpbuf, 128,
"Today is %A, day %d of %B in the year %Y.\n", today );
printf( tmpbuf );
return 0;
}
Posted 08 October 2010 - 10:07 PM
snoopy11, on 08 October 2010 - 08:49 PM, said:
#include <time.h>
#include <stdio.h>
int main()
{
char tmpbuf[128];
time_t ltime;
struct tm *today;
time( <ime );
today = localtime( <ime );
/* Use strftime to build a customized time string. */
strftime( tmpbuf, 128,
"Today is %A, day %d of %B in the year %Y.\n", today );
printf( tmpbuf );
return 0;
}
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
