Exemple #1
0
int main(void)
{
    char word[MAX_WORD_LEN+2];
    int word_len;

    clear_line();
    for (;;) {
        read_word(word, MAX_WORD_LEN+1);
        word_len = strlen(word);
        if (word_len == 0) {
            flush_line();
            return 0;
        }
        if (word_len + 1 > space_remaining()) {
            write_line();
            clear_line();
        }
        add_word(word);
    }
}
Exemple #2
0
int main(void)
{
    char word[MAX_WORD_LEN+2];
    int word_len;

    clear_line();
    for (;;) {
        read_word(word, MAX_WORD_LEN+1);
        word_len = strlen(word);
        //printf("THIS RAN 1 \n");
        if (word_len == 0) {
          //  printf("THIS RAN 2 \n");
            flush_line();
            return 0;
        }
        //printf("THIS RAN 11 \n");
        
        if (word_len > MAX_WORD_LEN){
            //printf("THIS RAN 3 \n");
            
            word[MAX_WORD_LEN] = '*';
        }
        //printf("THIS RAN 13 \n");
        
        if (word_len + 1 > space_remaining()) {
            printf("THIS RAN 4 \n");
            
            write_line();
            printf("THIS RAN 5 \n");
                
            clear_line();
            printf("THIS RAN 7 \n");
            
        }
        //printf("THIS RAN 18 \n");
        
        add_word(word);
        //printf("THIS RAN 8 \n");
        
    }
}
Exemple #3
0
int main(int argc, char *argv[])
{
  char word[MAX_WORD_LEN+2];
  int word_len;
  clear_line();
  for(;;) {
	  read_word(word, MAX_WORD_LEN+1);
	  word_len = strlen(word);
	  if (word_len == 0) {
		  flush_line();
		  return 0;
	  }
	  if (word_len > MAX_WORD_LEN) {
		  word[MAX_WORD_LEN] = '*';
	  }
	  if (word_len + 1 > space_remaining()) {
		  write_line();
		  clear_line();
	  }
	  add_word(word);
  }
  return 0;
}
Exemple #4
0
int main(void){
	
	char word[MAX_WORD_LEN + 2];
	int word_len;
	
	clear_line();
	
	for(;;){
		word_len = read_word(word, MAX_WORD_LEN + 1);
		if (word_len == 0){
			flush_line();
			return 0;
		}
		/*
			if (word_len > MAX_WORD_LEN)
				word[MAX_WORD_LEN] = '*';
		*/
		if (word_len + 1 > space_remaining()){
			write_line();
			clear_line();
		}
		add_word(word);
	}
}
void write_line(void)
{
	int padding, gaps_needed, extra_spaces, spaces_to_insert, i;
	
	extra_spaces = space_remaining();
	for (Node *n = line; n; n = n->next)
	{
		printf("%s", n->word);
		if(n->next)
		{
			gaps_needed = num_words - 1;
			padding = extra_spaces / gaps_needed;
			spaces_to_insert = 1 + padding;
			
			for (i = 1; i <= spaces_to_insert; i++)
			{
				putchar(' ');
			}
			extra_spaces -= padding;
			num_words--;
		}
	}
	putchar('\n');
}