Beispiel #1
0
int main() {
	char ch;
	welcomescreen();	
	printrule();	
	do {
		switch(mainmenu()) {
			case 0 :loadgame();
				break;
			case 1: controls();
				break;
			case 2: ;
				break;
		
			}
	
		printf("\nDo you want to play now ? ( Y OR N)\n");
		scanf("%c",&ch);
		ch = tolower(ch);	
	} while(ch =='y');
		
	clrscr();
	printf("Your score has been saved to Snake.txt\n");
	FILE *fp;
	fp = fopen("Snake.txt", "a");
	fprintf(fp,"Player score : %d\n", globscore);	
	printf("\n\nThanks for playing\n");
	fclose(fp);
return 0 ;

}		
Beispiel #2
0
/* error - report error and quit */
void error(char* s)
{
    fputs(s, stderr);
    if (activerule) {
        fputs("active rule:\n", stderr);
        printrule(activerule, stderr);
    }
    exit(1);
}
Beispiel #3
0
/**
 * Print the horizontal rule used in title/artist commands 
 */
void printrule(unsigned char n, inaction_t action)
{
  if (n == HEADER) {

    if ( action == artists || action == artist_search ) {
      printrule( 25, noop );
      printf(" ");
      printrule( 40,noop );
    } else { /* Must be title or title_search */
      printrule( 40, noop );
      printf(" ");
      printrule( 25, noop );
    }

    printf("%s"," ");
    printrule( 3, noop );
    printf("%s"," ");
    printrule( 5, noop );
    printf("%s","\n");
    return;
  }

  while (n > 0) {
    printf("%s","="); n--;
  }
}
Beispiel #4
0
char*
printrules(void)
{
	int i;
	char *s;

	s = nil;
	for(i=0; i<nvars; i++)
		s = concat(s, printvar(&vars[i]));
	for(i=0; i<nports; i++)
		s = concat(s, printport(ports[i]));
	s = concat(s, "\n");
	for(i=0; rules[i]; i++)
		s = concat(s, printrule(rules[i]));
	return s;
}
Beispiel #5
0
/** 
 * Print out the database for several different commands 
 *
 * @param head - the head node of the database to print
 * @param action - The application command we ant to display for:
 *                 artists
 *                 titles
 *                 artist searchterm
 *                 title searchterm
 *
 * @param search - optional paramater used as the term to search
 * for when using a search command.
 */
void print_action(dbentry* head, inaction_t action, char* search)
{
  dbentry* curr = head;
  bool artist_match;
  bool title_match;

  printf("\n");
  if (action == artists || action == artist_search) {
    printf("%-24s  %s %35s %s\n", "Name of Artist", "CD Title", "Trk", "Time");
  } else {
    printf("%-39s  %s %14s %s\n", "CD Title", "Name of Artist", "Trk", "Time");
  }

  printrule( HEADER, action );
  while ( curr )
  {
    if ( NULL == search ) {
      artist_match = false;
      title_match = false;
    } else {
      artist_match = (action == artist_search) && (NULL != strstr(curr->artist, search));
      title_match  = (action == title_search)  && (NULL != strstr(curr->title, search));
    }

    if ( action == artists || artist_match ) {

      printf("%-25s %-40s %3i %02i:%02i\n", curr->artist, curr->title, 
          (int) curr->tracks, (int)curr->time_m, (int)curr->time_s);

    } else if ( action == titles || title_match ) {

      printf("%-40s %-25s %3i %02i:%02i\n", curr->title, curr->artist,
          (int)curr->tracks, (int)curr->time_m, (int)curr->time_s);

    }
    curr = (action == artists || action == artist_search) ? curr->artist_next : curr->title_next;
  }
}