////=========================================================================================== // lire une ligne des commandes a partire du clavier void lire() { char *newligne = (char *)NULL; *ligne_glb = (char *)NULL; newligne = readline(colorer(attr_underline, fg_green, bg_black, Prompt)); sprintf (ligne_glb, "%s\n", newligne); sprintf (input, "%s\n", newligne); if (ligne_glb && *ligne_glb) add_history(ligne_glb); }
main() { char str[1000000]; int i,c; for(i=0; i<=1000000 && (c=getchar())!='\n'; ++i) { str[i] = c; } system("cls"); //tokenizer ver 2 char delims[] = " "; char inte[] = "int"; char chare[] = "char"; char *result = NULL; result = strtok( str, delims ); //tokenise the input string with the delimiter and give the pointer to each token to return variable while( result != NULL ) { //while result pointer is not null if(strcmp(result, inte)!=0){ printf( "%s ", result );//print the token to which the pointer points to } else if(strcmp(result, chare)==0){ colorer(result, BLUE); } else { colorer(result, RED); } result = strtok( NULL, delims );//set the pointer to the next delimiter position } getch(); }