Ejemplo n.º 1
0
int main(int argc, char *argv[]){ 
//Initialized Values
FILE *file, *fileOut;
int c = 0, d = 0, n=0;			       
int iocharStart;
int wordsValue=0;	//This is the return value which checks for errors
int checkReturn=0;	//checks if any past return value has occured from other files	       		       
char *extraCredit = "-o";
int exCredFound;
int exCredCheck=0;

if(argc >= 2){
    for(n = 1; n <= argc-1; n++){
        if(*(*(argv+n)) == *extraCredit){
	    if(n==argc-1){				//check if there is no filename after -o
	        fprintf(stderr,"No filename after -o\n");
	        return 4;
	    }
	    fileOut=fopen(*(argv+(n+1)), "w");
	    exCredFound=n+1;
	    exCredCheck=1;
	}   
    }
    for(n = 1; n <= argc-1; n++){			//if a file
    	if(n==exCredFound-1 || n == exCredFound){
		
	}
	else{    
            file=fopen(*(argv+n), "r");			//open file
	    if(file == 0){
	        fprintf(stderr,"File %s could not be opened\n",*(argv+n));
	        checkReturn=1;
	    }
	    else{
                iocharStart=getc(file);
	        wordsValue= printWords(iocharStart, argc, file,exCredCheck,fileOut);
	        if(wordsValue != 0) checkReturn=wordsValue;
	        fclose(file);
	    }
	 }
    }
}
else{						//if standard out
    iocharStart=getc(stdin);
    wordsValue= printWords(iocharStart, argc, 0,0,0);
}
if(checkReturn != 0) wordsValue=checkReturn;
  return wordsValue;
}
Ejemplo n.º 2
0
int main(int argv, char *argc){
	int i = 0,
		len = 0,
		lenSentence = 0,
		flag = 0;
	char sentence[WORD*WORDS];
	char ch;
	
	while((ch = getchar()) != '\n'){
		if(ch != ' '){
			flag = 0;
			sentence[i] = ch;
			i++;
			len++;
		}
		else if(flag == 0){
			flag = 1;
			sentence[i] = ch;
			i++;
			len++;
		}
	}

	lenSentence = checkSentence(len, sentence);
	checkWord(lenSentence, sentence);
	checkWords(lenSentence, sentence);
	printWords(lenSentence, sentence);

	system("PAUSE");
	return 0;
}
Ejemplo n.º 3
0
void printCommandList(command_t commList, int length)
{

	int i;
	printf("printCommandList\n");
	printf("length: %d\n", length);
	int k = commList[0].type == SIMPLE_COMMAND;
	printf("k: %d\n", k);
	for(i = 0; i < length; i++)
	{
		printf("%d ", i);
		switch(commList[i].type)
		{
			case AND_COMMAND: printf("AND_COMMAND\n"); break;
			case SEQUENCE_COMMAND: printf("SEQUENCE_COMMAND\n"); break;
			case OR_COMMAND: printf("OR_COMMAND\n"); break;
			case PIPE_COMMAND: printf("PIPE_COMMAND\n"); break;
			case SIMPLE_COMMAND: printf("SIMPLE_COMMAND\n"); //printf("commList[i].numWords: %d\n", commList[i].numWords);
									 printWords(commList[i].u.word, commList[i].numWords); break;
				break;
			case OPEN_PAREN: printf("OPEN_PAREN\n"); break;
			case CLOSED_PAREN: printf("CLOSED_PAREN\n"); break;
			case LEFT_REDIRECT: printf("LEFT_REDIRECT\n"); break;
			case RIGHT_REDIRECT: printf("RIGHT_REDIRECT\n"); break;
			case NEW_LINE: printf("NEW_LINE\n"); break;
			case IGNORE_COMMAND: printf("IGNORE_COMMAND\n"); break;
			default: break;
		}

	}
	printf("\n");
}
Ejemplo n.º 4
0
//Driver program
int main(void)
{
    int number[] = {2, 3, 4};
    int n = sizeof(number)/sizeof(number[0]);
    printWords(number, n);
    return 0;
}
void Individual::printDetail(ofstream &ofs){
    ofs << "Chars:\n";
    printChars(ofs);

    ofs << "Words:\n";
    printWords(ofs);
}
void Individual::printDetail(){
    cout << "Chars:\n";
    printChars();

    cout << "Words:\n";
    printWords();
}
Ejemplo n.º 7
0
int main()
{
    int num[7] = {2,3,4,5,6,7,8,};
    
    printWords(num);

    return 0;
}
Ejemplo n.º 8
0
/*	Name: promptUser 

	Description: Prompts user for input to be found within Trie.

	Parameters:
		Trie* T: A pointer to the Trie which autocomplete words will be found.
*/
void promptUser(Trie *T){
	char wordToFind[MAX_CHARS];
	// continues until user ends program.
	while(1){
		printf("Enter String: ");
		// get autocomplete word from standard input
		fgets(wordToFind, MAX_CHARS, stdin);
		// print autocomplete words
		printWords(T, wordToFind, (int) strlen(wordToFind));
	}
}
Ejemplo n.º 9
0
Archivo: ht.c Proyecto: wfei/hw
//hash_lookup
void hashLookup(HT hashTable, ElemType *input, int (*hashFun)(ElemType *words, int size)){
    ElemType inputTemp[keySize];
    strcpy(inputTemp, input);
    
    //reorder the user input
    sortWords(inputTemp);
    
    //calcuate hash value based on the user input
    int hValue = (*hashFun)(inputTemp, hashTable->tableSize);
    
    //print all the words with calculated hash value
    printWords(hashTable, hValue);
    
}//end of hashLookup
Ejemplo n.º 10
0
void printWords(int * number, int cur_pos, char *output, int n) {
	
	int i;
	if(cur_pos == n) {
		printf("%s\n", output);
		return;
	}

	for(i = 0; i<strlen(phone[number[cur_pos]]); i++) {
		output[cur_pos] = phone[number[cur_pos]][i];
		printWords(number, cur_pos+1, output, n);
		if(number[cur_pos] == 0 || number[cur_pos] == 1)
			return;
	}
}
Ejemplo n.º 11
0
Archivo: ww.c Proyecto: VeraJulian/ww
int main(int argc, char** argv)
{
  //Create a file pointer                                                       
  FILE* fp;

  //Check for file input                                                        
  if(argc > 1){

    //If there are multiple files read them all                                 
    while((--argc)>0){
      argv++;
      fp = fopen(argv[0],"r");

      //printWords will read the input and determine duplicate adjacent         
      //words in the files                                                      
      printWords(fp,argv[0]);
      fclose(fp);
    }
  }else{
    //If there are no files then read from stdin                                
    printWords(stdin,"stdin");
  }
  return 0;
}
Ejemplo n.º 12
0
int set(String args) 
{
    //Clear LCD
    lcd.clear();
    lcd.setCursor(0, 0);
    
    //Replace characters
    args.replace("%20", " ");
    args.replace("%27", "'");
    
    printWords(args);
    
    //Schedule flash
    flash_counter = 5;
    
    return 0;
}
Ejemplo n.º 13
0
int main() {
	
	int * number;
	int n;

	printf("Enter number of elements: ");
	scanf("%d", &n);
	
	number = (int *)malloc(n*sizeof(int));

	for(int i=0; i<n; i++)
		scanf("%d", &number[i]);
	
	char *output;
	output = (char *)malloc((n+1)*sizeof(char));
	output[n] = '\0';
	printWords(number, 0, output, n);
	
	return 0;
}
Ejemplo n.º 14
0
void Control::print(){
    bg.print();
    printWords();
}