segmentation default
take what you need
Tuesday, 13 December 2011
Create a file with C
Write void makefile(const char * filename, int length); which writes a file of the specified length. The contents of the file should all be 0.
#include <stdio.h> #include <stdlib.h> // Writing a file of the specified length containing all 0 void makefile(const char * filename, int length){ // New File FILE * fileToWrite; fileToWrite = fopen( filename,"w"); if( fileToWrite != NULL){ for(int i = 0; i < length; i++){ fputc('0',fileToWrite); } } fclose(fileToWrite); } int main(){ makefile("newFile0",0); makefile("newFile1",1); makefile("newFile40129",40129); }
Exercise from:
CS3008
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment