1
Name:
Anonymous
2009-04-14 12:59
Write a program in your language that
1.opens a file as arbitrary precision integer.
2.divides the number by 3.
3.stores the binary result in another file.
11
Name:
Anonymous
2009-04-14 14:06
#define FUNCTION_RETURN_TYPE void
#define FUNCTION_NAME writeLoop
#define FUNCTION_PARAMETERS void
#define START_FUNCTION {
#define END_FUNCTION }
#define OPENING_DEVICE file
#define OPENING_FUNCTION open
#define WRITING_FUNCTION write
#define CLOSING_FUNCTION close
#define FILE_READ_NAME someFile
#define FILE_WRITE_NAME anotherFile
#define MATH_OPERATION /
#define MATH_OPERATION_VALUE 3
#define NUMBER_OF_FILES 1
#define LOOP_INITIAL 0
#define INCREMENT += 1;
#define FOR_LOOP_BEGIN for
#define FOR_INITIALIZE_BEGIN (
#define FOR_INITIALIZE_END ;
#define FOR_CONDITION_BEGIN
#define FOR_CONDITION_END ;
#define FOR_INCREMENT_BEGIN
#define FOR_INCREMENT_END ) {
#define FOR_LOOP_END }
#define PARAMETERS_BEGIN (
#define PARAMETERS_END )
#define END_STATEMENT ;
#define INDEX_BEGIN [
#define INDEX_END ]
#define HEADERS #include <stdio.h> \
#include <sys/stat.h> \
#include <unistd.h> \
#include <fcntl.h> \
#include <stdlib.h>
HEADERS
typedef int arbitrary_precision_integer_t;
FUNCTION_RETURN_TYPE
FUNCTION_NAME
PARAMETERS_BEGIN
FUNCTION_PARAMETERS
PARAMETERS_END
START_FUNCTION
int loopCount, readFile, writeFile;
arbitrary_precision_integer_t arbitraryPrecisionIntegerFiles[NUMBER_OF_FILES];
FOR_LOOP_BEGIN
FOR_INITIALIZE_BEGIN
loopCount = LOOP_INITIAL;
FOR_INITIALIZE_END
FOR_CONDITION_BEGIN
loopCount < NUMBER_OF_FILES
FOR_CONDITION_END
FOR_INCREMENT_BEGIN
loopCount INCREMENT;
FOR_INCREMENT_END
readFile = OPENING_DEVICE.OPENING_FUNCTION
PARAMETERS_BEGIN
FILE_READ_NAME,
O_RDONLY
PARAMETERS_END
END_STATEMENT
writeFile = OPEN_DEVICE.OPENING_FUNCTION
PARAMETERS_BEGIN
FILE_WRITE_NAME,
O_WRONLY | O_APPEND
PARAMETERS_END
END_STATEMENT
WRITE
PARAMETERS_BEGIN
writeFile,
readFile MATH_OPERATION MATH_OPERATION_VALUE,
sizeof(int)
PARAMETERS_END
END_STATEMENT
CLOSING_FUNCTION
PARAMETERS_BEGIN
writeFile
PARAMETERS_END
CLOSING_FUNCTION
PARAMETERS_BEGIN
readFile
PARAMETERS_END
FOR_LOOP_END
END_FUNCTION
There, that's closer to something to work with. I think I started writing SEPPLES on the last one.