int main(int argc, char *argv[]){ int x; x = 10; incrementa(&x); printf("%d",x); return 1; }
void B::prueba(int i) { a_pub=i; a_pro=i; // a_pri=i; error i=incrementa(i); }
int main(int argc,char**argv) { int i,j,fin; int pos[]={0,0,0,0,0,0,0,0,0,0}; char *conjunto="ABCDEFGHIJKLMNÑOPQRSTUVWXYZ"; if (argc>1) { NUM_CHARS=atoi(argv[1]); } if (argc>2) { MAX=atoi(argv[2]); } if (argc>3) { conjunto=argv[3]; if (NUM_CHARS>strlen(conjunto)) { NUM_CHARS=strlen(conjunto); } } for(i=0;i<MAX;i++) { fin=0; while(!fin) { for(j=0;j<=i;j++) { printf("%c",conjunto[pos[j]]); } fin=incrementa(pos,i); printf("\n"); } } }
void insertElemInBuffer(buffer *b, buffer_element elem) { sem_wait(&b->empty); sem_wait(&b->mutex_tail); *(b->tail) = elem; b->tail = incrementa(b, b->tail); sem_post(&b->mutex_tail); sem_post(&b->full); }
buffer_element getElemFromBuffer(buffer *b) { sem_wait(&b->full); sem_wait(&b->mutex_head); buffer_element ret = *(b->head); b->head = incrementa(b, b->head); sem_post(&b->mutex_head); sem_post(&b->empty); return ret; }
/*definição de funções de teste */ void testaIncrementa() { printf("<funcao incrementa>\n"); int a=2,b=3,c=10; /*teste 1*/ incrementa(&a,b); if(a == 5) { printf(" teste 1: ok.\n"); } else { printf(" teste 1: not ok.\n"); } /*teste 2*/ incrementa(&a,c); if(a == 15) { printf(" teste 2: ok.\n"); } else { printf(" teste 2: not ok.\n"); } }