Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* PROGRAM: itr.c
- AUTHOR:
- DATE:
- TOPIC: SBA
- PURPOSE: SBA
- NOTES:
- */
- #include <ctype.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <string.h>
- #define MAX_WORD 45
- void itr( const char *file, int tr, char *c );
- /**************************************************************************/
- /* MAIN
- **************************************************************************/
- int main(int argc, char *argv[] ) {
- char *filename[MAX_WORD];
- char transform = 'i';
- char *point;
- int tr = 0;
- filename[MAX_WORD] = (char *)malloc(sizeof(char) * MAX_WORD);
- filename[MAX_WORD] = argv[MAX_WORD];
- point = (char *)malloc(sizeof(char) * 1);
- point = transform;
- itr(filename, tr, point);
- free(point);
- return 0;
- }
- /**************************************************************************/
- /* itr:
- const char * file: filename of the file to be process
- int tr : transformation type ( d or s )
- char *c : char to be transformed
- **************************************************************************/
- void itr( const char *file, int tr, char *c ){
- char *line;
- FILE *fp;
- if((fp = fopen(file[1], "r")) == NULL) {
- perror("fopen");
- exit(EXIT_FAILURE);
- }
- if((line = (char *)malloc (sizeof(char) * MAX_WORD)) == NULL){
- perror("malloc line");
- exit(EXIT_FAILURE);
- }
- while(fgets(line, MAX_WORD, fp) != NULL){
- printf("%s\n", line);
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement