/* 2colors.c
* written by Myst Shen on Sep. 16, 2008.
*/
#include <stdio.h>
#include <ctype.h>
#include "myst_color.h"
int x, y, c, num;
NODE *h;
FILE *fp;
char *color1;
char *color2;
int main (int argc, char *argv[]){
int j=0;
if (argc != 3) {
printf ("Illegal arguments.\n");
exit(0);
}
if (!(isdigit(*argv[1]))) {
printf ("The first argument should be a digit!\n");
exit(0);
}
fp = fopen(argv[2],"r");
if (!fp) {
printf ("Sorry, cannot open this file !.\n");
exit(0);
}
h = init(fp);
color1 = rand_color(1);
color2 = rand_color(0);
p = h;
while (1){
if( p == NULL ) break;
if (p->val == '\n') j=0;
j++;
if (j > atoi(argv[1])) {
p->color = color1;
}
else {
p->color = color2;
}
p = p->next;
}
print(h);
return 0;
}
|