knokap4 - /* * Name - Kimberly Okafor Email -...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* *************************************************** Name - Kimberly Okafor Email - [email protected] ECE 3331 Computer Problem 4 Semester - Spring 2010 *************************************************** Purpose - to translate english to pig-latin or pig- latin to english *************************************************** Data files cp41010.txt - input data file containing the codes and passages that are looking to be translated knokap4.out - output file to which results will be written *************************************************** */ /*included files*/ #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <ctype.h> /*prototypes*/ void english2pig (char inword[], char outword[]); int pig2english (char inword[], char outword1[], char outword2[]); main() { /*declarations*/ char word[72]; /*word from txt file looking to be translated*/ char inword[72]; /*the word without the punctuation*/ char indicator; /*e or p*/ int passage; /*passage number*/ char testeng[]="there.",outword1[70],outword2[70]; /*test variables*/ char engoutword1[72]; /*the 1st version of the english translation of the pig- latin word*/ char engoutword2[72]; /*the 2nd version of the english translation of the pig- latin word*/ char pigoutword[74]; /*the pig-latin translation of an english word*/ int engnum; /*the number of english words that the pig-latin word can be*/ int count; /*counter*/ /*file pointer*/ FILE *fin,*fout; /*input data read from cp41010.txt*/ fin=fopen("cp41010.txt","r"); /*output goes to this file*/ fout=fopen("knokap4.out","w"); /*print title of project */ fprintf(fout,"Kimberly Okafor \nECE 3331 Project 4 Spring 2010 \n\n\n"); /*initialize passage number*/ passage=0;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
{ /*dummy check printf("indicator=%c \n",indicator);*/ if (indicator=='e') { fprintf(fout,"\n\n"); passage+=1; fprintf(fout,"Passage %d \n\n",passage); while(fscanf(fin,"%[^ \n//\n]\n ",word)>0) { /*dummy check. punctuation check happens in the loop printf("english word= %s\n",word);*/ /*check if there is punctuation in the word*/ /*if(ispunct(word[strlen(word)-1])!=0) { */ for(count=0;count<strlen(word);count++) { inword[count]='\0'; } /*inword is word without the punctuation for(count=0;count<(strlen(word)+1);count++) { inword[count]=word[count]; }/*end of inword for*/ /*translate the english word english2pig(inword,pigoutword); fprintf(fout," %s%c ",pigoutword,word[strlen(word)-1]); }/*end of if else {*/ /*remove the new line*/ english2pig(word,pigoutword); /* printf("the word is %s its length is %d and the translation is %s\n",word,strlen(word),pigoutword);*/ fprintf(fout," %s ",pigoutword); }/*end of while*/
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/26/2011 for the course ECE 3331 taught by Professor Staff during the Fall '08 term at University of Houston.

Page1 / 8

knokap4 - /* * Name - Kimberly Okafor Email -...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online