root/misc/4pallo.c

Revision 1219, 1.1 kB (checked in by alpt, 1 year ago)

improved

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * 4pallo.c: Makes a string cycles inside a buffer.
3  *
4  * Una noiosa notte di Giugno 2003, By Alpt
5  * Aggiornato il Tue Mar 28 11:24:58 CEST 2006
6  */
7
8
9 #include <stdlib.h>
10 #include <string.h>
11 #include <unistd.h>
12 #include <stdio.h>
13
14 int main()
15 {
16         char alpt[]="1234567890abcdef";
17         char small[80];
18         int y,i,len;
19        
20         len=strlen(alpt);
21         for(y=0; y!=len+1;y++) {       
22                 strncpy(small, alpt, 80);
23                 small[79]=0;
24                 printf("\r%s", small);
25                 fflush(stdout);
26                 sift(alpt,len);
27                 usleep(90000);
28         }
29         printf("\n");
30 }
31
32
33 /*Penso che questo algoritmo ti posso essere utile per i link lunghi
34  * Hai presente xmms? Quando ci sono titoli lunghi incomincia a farli roteare in
35  * continuazione. Bene con questo puoi fare lo stesso. Bada che modifica direttamente la stringa
36  * in input, ma puoi riportarla allo stato origininale facendola shiftare n+1 volte, per n uguale
37  * alla lunghezza della stringa.
38  * Ovviamente puoi mettere anche un sleep nel ciclo per renderela visibile ;)
39  * And that's all!
40  * Cy4!
41  */
42 int sift(char *alpt, int len)
43 {
44         int i;
45
46         for(i=len; i!=-1; i--)
47                 if((i-1)<0)
48                         alpt[i]=alpt[len];
49                 else
50                         alpt[i]=alpt[i-1];
51         alpt[len]='\0';
52 }
Note: See TracBrowser for help on using the browser.