Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void readFiles(FILE *file1, List *theList, int fileNum) {
- int i, lineIndex;
- char *newLine;
- size_t lineLength = 0;
- while(lineLength=getline(&newLine, &lineLength, file1)>0){
- lineIndex = 0;
- i = 0;
- char *newWord;//saves individual words
- while(newLine[lineIndex] != '\0'){ //move to new space
- if(newLine[lineIndex] == ' '){
- //insert(&theList, parseWord(i, newWord), fileNum);
- parseWord(i, newWord);
- i = 0;
- }else{
- newWord[i] = newLine[lineIndex];
- i++;
- }
- lineIndex++;
- }
- }
- }
- char *parseWord(int theLen, char *theWord){
- char cleanWord[theLen]; //the word without other stuff
- char *finalWord;
- int i, j;
- for(j = i = 0; i < theLen; i++) {
- char tmp = theWord[i];
- if (tmp >= 'A' && tmp <= 'Z') {
- cleanWord[j] = tolower((unsigned char) theWord[i]);
- j++;
- } else if ((tmp >= 'a' && tmp <= 'z') || tmp == 39 || tmp == 45) {
- cleanWord[j] = theWord[i];
- j++;
- }
- }
- return strcpy(finalWord, cleanWord);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement