Open main menu

CDOT Wiki β

Changes

Assignment 3i: Q & A

1,089 bytes added, 22:00, 27 November 2012
no edit summary
More info here: [http://www.cplusplus.com/reference/stl/vector/erase/ Vector erase()]
(Submitted by Kevin Kofler, Team 9)<br> <br>'''Q:''' How to get current system time using c++?<br>'''A:''' There is time_t data type in c++ which when passed as an argument to time function represents calendar time.<br> Its actual value is number of seconds elapsed since 00:00:00 on January 1, 1970. Following code snippet will print your current system time.<br><source lang=html4strict> #include <ctime> #include <cstdio> using namespace std; int main() { time_t ltime; time(&ltime); printf("Size of time_t is %d\n",sizeof(time_t)); printf("Time is %s\n",ctime(&ltime)); return 0; }</source>'''Submitted by:''' Shajinth Pathmakulaseelan, Team 2 <br><br> '''Q:''' What is the easiest way to delete all the contents of file? <br>'''A:''' The easiest way to delete all contents of file is to open file in write mode.<br> When we open file in write mode then if file exists all its previous contents are erased and writing will start from the very beginning.<br><source lang=html4strict> FILE *fp = fopen("filename","w");</source> '''Submitted by:''' Shajinth Pathmakulaseelan, Team 2 <br><br>