Ir para conteúdo
Fórum Script Brasil

Inufelipe

Membros
  • Total de itens

    186
  • Registro em

  • Última visita

Tudo que Inufelipe postou

  1. Inufelipe

    New[] e Classes

    Olá pessoal, tinha abandonado um pouco a programação mas agora estou voltando. Achei legal que lembrava a maioria dos comandos. Mas, me deparei com um problema novo. Como é que uso new myClass(a,b,c)[n]? Isto é, como é que eu combino o New[] com o construtor de uma classe? Dei uma boa procurada na documentação e até num livro que eu tenho aqui em casa. Mas, não falam de nada disso. Eu vi uma solução que eu devo alocar a memória e depois usar "for" para chamar o construtor. Foi essa solução que eu estava usando, mas esta me dando SegFalt e eu desconfio que isso deve ser alguma gambiarra. Grato desde já.
  2. E aí galera do Script Brasil Fórum? Eu estou com um problema já faz um bom tempo, e eu pesquisei já bastante coisa na Internet. É o seguinte, eu tenho Linux em um computador que se liga a um Router/Modem da DLINK(500G). Eu procurei no site da ABUsAR, e encontrei um tutorial. Seguindo este tutorial eu configurei meu NAT da seguinte forma: Rule ID: 2 Rule Flavor: RDR IF Name: ALL Protocol: ANY Local Address From: 10.1.1.25 Local Address To: 10.1.1.25 Global Address From: 0.0.0.0 Global Address To: 0.0.0.0 Destination Port From: 8000 Destination Port To: 8000 Local Port: 8000 Feito isto, acontece que quando eu acesso: meuip:8000 --------------> Erro 10.1.1.1:8000 ------------> Erro 10.1.1.25:8000 ----------> Funciona localhost:8000 -----------> Funciona O que está havendo, como eu posso concertar?
  3. Olá galera do Script Brasil Fórum. Eu estou ajudando na construção de um site, no qual nos baseamos por inteiro no navegador Firefox. O problema é que várias pessoas acessam pelo Internet Explorer. O site é http://www.inverta.org. Quem puder comparar verá que no IE: * o topo não estica para toda página. * o fundo, transparente, das imagem aparecem branco * aparece uma listra vertical no lado esquerdo do logo pois o background-image não o preenche * a barra da direita tem seus conteúdos sobre-saidos Esses são os erros mais graves. Alguém saberia alguma documentação que resolvessem-os, ou alguém poderia ajudar-me nesse problema que não vejo solução . . . Desde já estou grato.
  4. Salve galera do Script Brasil Forum. Eu estou desenvolvendo um script em pyhton e ele precisa abrir um arquivo txt e escrever algo para que fique gravado. Eu tentei usar a função open() do python mas ele retorna: NameError: global name 'open' is not defined ??? Se alguém poder me ajudar... O codigo-fonte: from Products.PythonScripts.standard import html_quote from Products.CMFCore.utils import getToolByName request = context.REQUEST RESPONSE = request.RESPONSE file = request.get('image',None) filename = file.filename folder = getattr(context, context.id) FILE = open("masterreg.txt","r") con = int(FILE.read()) close(FILE); #forma para adicionar imagem dentro do Plone folder.invokeFactory('Image', id=(str(con)), file=file) con = con+1 f = open("masterreg.txt","w") f.write(con) O traceback: Traceback (innermost last): Module ZPublisher.Publish, line 119, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 42, in call_object Module Shared.DC.Scripts.Bindings, line 313, in __call__ Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec Module Products.Hotfix_20080812, line 152, in _exec Module None, line 9, in imageupload.py - <PythonScript at /hosting_home/slot17301/site17442/scripts-de-gerencimento/imageupload.py> - Line 9 NameError: global name 'open' is not defined
  5. O erro era simples: em vez de: a = string(a) usei: a = str(a) Pois string é o modulo, str é a função que converte em string
  6. Olá galera do script brasil forum! Eu estou com um problema que não acho solução... "'module' object is not callable " não sou muito experiente em python, e já agradeço desde já a ajuda. A seguir colo o codigo fonte e o traceback traceback: * Module ZPublisher.Publish, line 119, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 42, in call_object * Module Shared.DC.Scripts.Bindings, line 313, in __call__ * Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec * Module Products.PythonScripts.PythonScript, line 327, in _exec * Module None, line 24, in auto_publish.py <PythonScript at /hosting_home/slot17301/site17442/scripts-de-gerencimento/auto_publish.py> Line 24 * Module None, line 4, in felipe_makeId <PythonScript at /hosting_home/slot17301/site17442/scripts-de-gerencimento/auto_publish.py> Line 4 Source code/ codigo fonte from Products.CMFCore.utils import getToolByName from AccessControl import getSecurityManager def felipe_makeId(a): a = string(a) a = a.lower() a = a.replace('ç','c') a = a.replace('ã','ã') a = a.replace('á','a') a = a.replace('â','a') a = a.replace('à','a') a = a.replace('é','e') a = a.replace('ê','e') a = a.replace('í','i') a = a.replace('ó','o') a = a.replace('ô','o') a = a.replace('ô','o') a = a.replace('ú','u') a = a.replace('ü','u') a = a.replace(' ','_') return a urltool = getToolByName(context, "portal_url") catalog = getToolByName(context, "portal_catalog") portal = urltool.getPortalObject(); makeRoot = portal.invokeFactory("Folder",felipe_makeId(edic)) root = getattr(portal,felipe_makeId(edic)) root.setTitle(edic) dirs = master.split(";") for x in dirs: x = x.split(":") tmp = root.invokeFactory("Folder", felipe_makeId(x[0])) tmp = getattr(root,felipe_makeId(x[0])) tmp.setTitle(x[0]) catalog.refreshCatalog() Se isso ajuda, eu estou programando sobre uma plataforma ZOPE em PLONE. Grato
  7. Olá galera do Script Brasil Forum! Eu estou com um problema onde eu programei um site sobre a base plone e ficou perfeito no firefox. O problema foi no Internet Explorer... Ele "come" algumas partes do sites, as quais sofrem a regra "margin-top - x px;"... asdasd --> Não mostra no IE pois fica acima da área da div ____________ asdasd --->DIV ____________ o site para quem quizer ver mais afundo é: http://inverta.objects.net Já desde agora agradeço. INUFELIPE
  8. Olá galera do Forum do Script Brasil. Se eu faço isto em java script: x = "abcde fghi klmn opq rs t uvx z" não funciona. Tipo ele lê só até o final da linha. Ai eu sei que não tem sentido, mas quando eu carrego do banco de dados algum texto que tenha "\n" ele fica assim. Não tem um comando que mande ele ler até achar a " ? Falous
  9. Ola galera do Forum do Script Brasil. Eu estou precisando da ajuda de vocês: Eu estou criando meu portifólio e tenho o seguinte problema, onde há o item b não funciona corretamente, por que será ? <HTML> <HEAD> <TITLE>Portifolio ShowRoom</TITLE> <STYLE> .k{ background-color:#66ccff; margin:0px 0px 1px 0px; padding:2px; padding-left:10px; width:100px; border-right:30px solid #333333; cursor:pointer; } .l{ background-color:#99ddff; margin:0px 0px 0px 0px; padding:0px; padding-left:15px; width:95px; border-right:30px solid #666666; cursor:pointer; opacity:0; height:0px; } </STYLE> <BODY> <DIV class="k" onmouseover="a = 1" onmouseout="a = 0" onclick="b = 1" id="i1">Item a</DIV> <DIV class="l" id="j1">Subitem a</DIV> <DIV class="l" id="j2">Subitem b</DIV> <DIV class="l" id="j3">Subitem c</DIV> <DIV class="k" onmouseover="a = 2" onmouseout="a = 0" id="i2">Item b</DIV> <DIV class="k" onmouseover="a = 3" onmouseout="a = 0" id="i3">Item c</DIV> <DIV class="k" onmouseover="a = 4" onmouseout="a = 0" id="i4">Item d</DIV> <DIV class="k" onmouseover="a = 5" onmouseout="a = 0" id="i5">Item e</DIV> <DIV class="k" onmouseover="a = 6" onmouseout="a = 0" id="i6">Item f</DIV> &lt;script> a = 0 b = 0 i = 10; j = 100; m = 6 n = 3 function start(){ z = 0; while(z<m){ z++; document.getElementById(("i")+(z)).style.paddingLeft=10; document.getElementById(("i")+(z)).style.width=100; } z = 0; while(z<n){ z++; document.getElementById(("j")+(z)).style.height=0; document.getElementById(("j")+(z)).style.padding=0; document.getElementById(("j")+(z)).style.paddingLeft=0; document.getElementById(("j")+(z)).style.marginBottom=0; document.getElementById(("j")+(z)).style.opacity=0; } ani(); } function set(n){ } function ani(){ z = 0; while(z<m){ z++; if(a != z){ if(parseInt(document.getElementById(("i"+(z))).style.paddingLeft) > 10){ document.getElementById(("i"+(z))).style.paddingLeft = parseInt(document.getElementById(("i"+(z))).style.paddingLeft)-(1); } if(parseInt(document.getElementById(("i"+(z))).style.width) < 100){ document.getElementById(("i"+(z))).style.width = parseInt(document.getElementById(("i"+(z))).style.width)+(1); } } else{ if(parseInt(document.getElementById(("i"+(z))).style.paddingLeft) < 20){ document.getElementById(("i"+(z))).style.paddingLeft = parseInt(document.getElementById(("i"+(z))).style.paddingLeft)+(1); } if(parseInt(document.getElementById(("i"+(z))).style.width) > 90){ document.getElementById(("i"+(z))).style.width = parseInt(document.getElementById(("i"+(z))).style.width)-(1); } } } z = 0; while(z<n){ z++; if(b != z){ if(parseInt(document.getElementById(("j"+(z))).style.height) > 0){ document.getElementById(("j"+(z))).style.height = parseInt(document.getElementById(("j"+(z))).style.height)-(1); } if(parseInt(document.getElementById(("j"+(z))).style.padding) > 0){ document.getElementById(("j"+(z))).style.padding = parseInt(document.getElementById(("j"+(z))).style.padding)-(1); } if(parseInt(document.getElementById(("j"+(z))).style.paddingLeft) > 0){ document.getElementById(("j"+(z))).style.paddingLeft = parseInt(document.getElementById(("j"+(z))).style.paddingLeft)-(1); } if(parseInt(document.getElementById(("j"+(z))).style.marginBottom) > 0){ document.getElementById(("j"+(z))).style.marginBottom = parseInt(document.getElementById(("j"+(z))).style.marginBottom)-(1); } if(parseFloat(document.getElementById(("j"+(z))).style.opacity) > 0){ document.getElementById(("j"+(z))).style.opacity = parseFloat(document.getElementById(("j"+(z))).style.opacity)-(0.1); } } else{ if(parseInt(document.getElementById(("j"+(z))).style.height) < 20){ document.getElementById(("j"+(z))).style.height = parseInt(document.getElementById(("j"+(z))).style.height)+(1); } if(parseInt(document.getElementById(("j"+(z))).style.padding) < 2){ document.getElementById(("j"+(z))).style.padding = parseInt(document.getElementById(("j"+(z))).style.padding)+(1); } if(parseInt(document.getElementById(("j"+(z))).style.paddingLeft) < 15){ document.getElementById(("j"+(z))).style.paddingLeft = parseInt(document.getElementById(("j"+(z))).style.paddingLeft)+(1); } if(parseInt(document.getElementById(("j"+(z))).style.marginBottom) < 1){ document.getElementById(("j"+(z))).style.marginBottom = parseInt(document.getElementById(("j"+(z))).style.marginBottom)+(1); } if(parseFloat(document.getElementById(("j"+(z))).style.opacity) < 1){ document.getElementById(("j"+(z))).style.opacity = parseFloat(document.getElementById(("j"+(z))).style.opacity)+(0.1); } } } t = setTimeout("ani()",10); } start(); </SCRIPT> </BODY> </HEAD> </HTML> ou podem acesar o link clicando aqui. Valeu
  10. Olá galera do Script Brasil. Eu estou com um problema, na parte que eu tenho mais dificuldade que é a de ponteiros sempre dá algum erro mais depois que eu faço funcionar fica uma beleza, que é: main.cpp:137: error: cannot convert ‘char (*)[100]’ to ‘char**’ for argument ‘1’ to ‘void spaceless(char**)’ o codigo fonte é: #include <SDL/SDL.h> #include <SDL/SDL_image.h> #include <SDL/SDL_ttf.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <netdb.h> #include <sys/types.h> #include <netinet/in.h> #include <sys/socket.h> #define PORT 2842 TTF_Font *cotaba; SDL_Color BLACK = {0,0,0}; SDL_Event event; void spaceless(char **spaced){ int i=sizeof(spaced); int j=0; int k=0; while(1){ if(k = (i-j)){ spaced[j] = ''; } if(k > (i-j)){ free(spaced[j]); } else{ if(spaced[j][0] == ' '){ k++; spaced[j] = spaced[j+k]; } } if(i==j){ break; } j++; } printf("%s",spaced); } class NIN_button{ public: void clicked(){ if(event.button.y > 545 && event.button.y < 590 && event.button.x > 10 && event.button.x < 100){ printf("OK\n"); } } }; class NIN{ public: NIN_button button; }; SDL_Surface *load_image(char *file){ SDL_Surface *loaded; SDL_Surface *optimized; loaded = IMG_Load(file); optimized = SDL_DisplayFormat(loaded); SDL_FreeSurface(loaded); return optimized; } void show(int x, int y, SDL_Surface *source, SDL_Surface *dest){ SDL_Rect offset; offset.x = x; offset.y = y; SDL_BlitSurface(source,NULL,dest,&offset); } int main(int argc, char **argv){ int client,numbits,msgk=0; char buf[100]; struct hostent *he; struct sockaddr_in server; bool quit=0,conn=0; SDL_Surface *background; SDL_Surface *message; SDL_Surface *screen; if(SDL_Init(SDL_INIT_EVERYTHING)==-1){ printf("SDL INIT ERROR\n"); exit(1); } if(TTF_Init()==-1){ printf("SDL TTF INIT ERROR\n"); exit(1); } if((cotaba = TTF_OpenFont("img/cotaba.ttf",14))==NULL){ printf("COTABA FONT INIT ERROR\n"); exit(1); } if((screen = SDL_SetVideoMode(800,600,32,SDL_SWSURFACE))==NULL){ printf("SDL VIDEO MODE SET ERROR\n"); exit(1); } SDL_WM_SetCaption("NIn - Nible In",NULL); background = load_image("img/background.png"); show(0,0,background,screen); if((he = gethostbyname("127.0.0.1"))==NULL){ printf("SOCKET GETHOSTBYNAME ERROR\n"); exit(1); } if((client = socket(PF_INET,SOCK_STREAM,0))==-1){ printf("SOCKET FUNCTION ERROR\n"); exit(1); } server.sin_family = AF_INET; server.sin_port = htons(PORT); server.sin_addr = *((struct in_addr*)he->h_addr); memset(server.sin_zero,'',sizeof server.sin_zero); NIN NIn; SDL_Flip(screen); while(quit == 0){ while(SDL_PollEvent(&event)){ switch(event.type){ case SDL_QUIT: quit=1; break; case SDL_MOUSEBUTTONDOWN: NIn.button.clicked(); } } if(conn==0){ if(connect(client,(struct sockaddr*)&server,sizeof server) ==-1){ msgk = 2; printf("ka\n"); } else{ msgk = 1; printf("ks\n"); } if ((numbits=recv(client, buf, 100-1, 0)) == -1) { perror("recv"); exit(1); } spaceless(&buf); printf("%d",numbits); buf[numbits] = ''; printf("Received: %s",buf); conn=1; } switch(msgk){ case 0: message = TTF_RenderText_Solid(cotaba,"Conectando...",BLACK); break; case 1: message = TTF_RenderText_Solid(cotaba,"Servidor_Pronto",BLACK); break; case 2: message = TTF_RenderText_Solid(cotaba,"Nao_foi_possivel_conectar_ao_servidor",BLACK); break; } show(140,555,message,screen); SDL_Flip(screen); } SDL_FreeSurface(background); SDL_FreeSurface(message); SDL_Quit(); return 0; }; Se alguém souber um bom site que tenha algo muito esclarecedor sobre ponteiros eu aceito!!! E se alguém quiser colaborar ajudando-me a desvendar "O Segredo do Ponteiros de Meu codigo" eu fico muito grato.
  11. Consegui assim: fscanf(file,"%[\t\r\n \x21-\x7E]",&index);
  12. Cara, muito obrigado!!! Porém como esperado quando eu ponho mais de uma linha no arquivo que desejo ler, ele lê apenas uma linha. Não há um jeito de fazer algo como: fscanf(fp,"%[EOF]",&index); onde EOF é end of file, que é um marcador que há no final do arquivo. OBRIGADO
  13. Ola Galera do Script Brasil!!! Eu tenho este codigo: /* ** server.c -- a stream socket server demo */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/wait.h> #include <signal.h> #define MYPORT 2833 // the port users will be connecting to #define BACKLOG 10 // how many pending connections queue will hold void sigchld_handler(int s) { while(waitpid(-1, NULL, WNOHANG) > 0); } void n2d(char *str){ int i = 0; while(str[i] != ''){ if(str[i] == ' '){ str[i] = '$'; } i++; } } int main(void) { int sockfd, new_fd; // listen on sock_fd, new connection on new_fd struct sockaddr_in my_addr; // my address information struct sockaddr_in their_addr; // connector's address information socklen_t sin_size; struct sigaction sa; int yes=1; if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); } if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) { perror("setsockopt"); exit(1); } my_addr.sin_family = AF_INET; // host byte order my_addr.sin_port = htons(MYPORT); // short, network byte order my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP memset(my_addr.sin_zero, '', sizeof my_addr.sin_zero); if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr) == -1) { perror("bind"); exit(1); } if (listen(sockfd, BACKLOG) == -1) { perror("listen"); exit(1); } sa.sa_handler = sigchld_handler; // reap all dead processes sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART; if (sigaction(SIGCHLD, &sa, NULL) == -1) { perror("sigaction"); exit(1); } FILE *file; char index[80]; file = fopen("index.nin","r"); fscanf(file,"%[A-Z][[:space:]][a-z][0-9]",&index); printf("%s\n",index); n2d((char*)&index); printf("%s\n",index); while(1) { // main accept() loop sin_size = sizeof their_addr; if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr, \ &sin_size)) == -1) { perror("accept"); continue; } printf("server: got connection from %s\n", \ inet_ntoa(their_addr.sin_addr)); if (!fork()) { // this is the child process close(sockfd); // child doesn't need the listener if (send(new_fd, index, 80, 0) == -1) perror("send"); close(new_fd); exit(0); } close(new_fd); // parent doesn't need this } return 0; } e este arquivo: SHOW "well.png" O problema quando ele lê o arquivo ele para antes do espaço. Se alguém souber o problema... FALOU
  14. Olá galera do Script Brasil. Eu estou precisando ler um arquivo TXT em C++. Ele lê o arquivo, até antes do primeiro espaço(" "). Eu uso a biblioteca stdio.h que é padra de C. O programa que eu estou fazendo é em C++, porém ainda não sei usar "novidades" de: CIN<<blabla<<... se alguém souber como me ajudar... Já estou grato. OBS:: Quando eu uso esta mesma função para ler a entrada padrão ela também lê só até o primeiro " ". Valeu galera do Script Brasil. Viva nossa comunidade!!!
  15. Olá galera do Script Brasil Forum. Eu estou tentando gravar um filme caseiro em formato de DVD. O mandvd faz isso muito bem porrem quando eu fui testar o som esta com muito ruido e ficou ruim... Não há um jeito de arrumar este problema ? OBS:: A pasta Audio do DVD estava vaizia... falous
  16. Olá galera do Script Brasil, Oque significa o aviso abaixo? "expected constructor, destructor, or type conversion before ‘(’ token" E como eu posso arrumar esse problema ? Falous
  17. Inufelipe

    Centralização No C!

    Isso presisa de um calculo matematico... exemplo: A tela tem 4 Caracteres de largura, e você quer escrever oi ( tem 2 caracteres ). (4 - 2)/2 = 1; dai você fala que para cada numero do resultado acima de um espaço, no caso: | oi | espero ter ajudado..
  18. Cara, não sei se o windows tem uma biblioteca para acessar o hardware... Mas tem como fazer em C++ usando um warper para o assembler... Porém eu não sei fazer isso.
  19. Inufelipe

    Freecell

    alocar as cartas não deve ser muito dificil: primeiro a estrutura da carta: struct Card{ int nipe; int number; } agora vamos alocar usando o malloc: Card *cards; cards = (Card*)malloc(sizeof(Card)*60); agora é definir aleatoriamente as cartas: int i=0; srand(time(NULL)); while(i<60){ cards[i].nipe = rand()%4; cards[i++].number = (rand()%12)+1; } Este é só um exemplo, pois ira repetir as cartas... Agora é só mostrar elas na tela. Espero ter ajudado...
  20. Valeu pela ajuda!!! Quando estiver pronto eu postarei o codigo completo para quem quizer comferir falous
  21. Ola galera do script brasil forum. Eu estou a criar um joguinho de cartas( ou cromos ), e estou usando o rand() e o srand(time(NULL)) para criar as cartas aleatoriamente e seus atributos, o problema é que não esta muito aleatorio porque as cartas se repetem, se alguém puder ajudar a tornar mais aleatorio eu agradeço. #include <stdio.h> #include <iostream> #include <stdlib.h> #include <time.h> int ra(){ int temp; temp = rand(); return temp; } void direction(int a, int b){ switch(b){ case 1: printf("Toda:"); break; case 2: switch(a){ case 0: printf("Topo e Esquerda:"); break; case 1: printf("Base e Direita:"); break; } break; case 4: switch(a){ case 0: printf("Topo:"); break; case 1: printf("Esquerda:"); break; case 2: printf("Base:"); break; case 3: printf("Direita:"); break; } break; } } class Cromo{ private: int colors; int *color; bool field; public: bool hand; Cromo(){} void set(int a){ colors = 1; hand = 0; field = 0; color = (int*)malloc(sizeof(int)); *color = a; } void set(int a,int b){ colors = 2; hand = 0; field = 0; color = (int*)malloc(sizeof(int)*2); color[0] = a; color[1] = b; } void set(int a,int b,int c, int d){ colors = 4; hand = 0; field = 0; color = (int*)malloc(sizeof(int)*4); color[0] = a; color[1] = b; color[2] = c; color[3] = d; } void random(){ int i=0; int temp; temp = (ra()%3)+1; switch(temp){ case 1: srand(time(NULL)); set(ra()%5); break; case 2: srand(time(NULL)); set(ra()%5,ra()%5); break; case 3: srand(time(NULL)); set(ra()%5,ra()%5,ra()%5,ra()%5); break; } }; void status(int j){ int i = 0; printf("\n%d:",j); while(i<colors){ switch(color[i]){ case 0: printf("\n\t"); direction(i,colors); printf("Vermelho"); break; case 1: printf("\n\t"); direction(i,colors); printf("Amarelo"); break; case 2: printf("\n\t"); direction(i,colors); printf("Verde"); break; case 3: printf("\n\t"); direction(i,colors); printf("Azul"); break; case 4: printf("\n\t"); direction(i,colors); printf("Branco"); break; } i++; } } }; class Table{ private: Cromo table[6][3]; public: Table(){ } }; class Book{ private: int cards; Cromo *card; int top_card; public: Book(){ } void set( int a ){ int i; top_card = 0; cards = a; card = (Cromo *)malloc(sizeof(Cromo)*a); for(i=0;i<a;i++){ card[i].random(); } buy(); buy(); buy(); } void buy(){ card[top_card++].hand = 1; } void show_hand(){ int i; while(i<cards){ if(card[i].hand == 1){ card[i].status(i); } i++; } } }; class Player{ private: Book book; public: Player(){ book.set(25); } void turn(){ printf("Mao:\n\n"); book.show_hand(); getchar(); book.buy(); } }; int main(){ srand(time(NULL)); Player p1,p2; bool turn = 0; while(1){ if(turn == 0){ p1.turn(); turn = 1; } if(turn == 1){ p2.turn(); turn = 0; } } }; falous
  22. Voce quer algo assim: #include <stdio.h> #include <stdlib.h> const int ROOT = -1; int id_last = 0; struct tree{ int id,father,content; }; tree allocIn(int value,int father){ tree temp; temp.id = id_last; temp.father = father; temp.content = value; return tree; id_last++; } tree* tree2array(int father_id){ int i = 0; int j = 0; tree *temp; while(i < id_last){ if(temp[i].father == father_id){ j++; } i++; } temp = (tree)malloc(sizeof(tree)*j); i = 0; j = 0; while(i < id_last){ if(temp[i].father == father_id){ temp[j++] = temp[i]; } i++; } return temp; } Desculpas, o codigo não ta muito bom... espero ter ajudado.
  23. Valeu pela explicação. Porem o memset não funcionou. Temtei com a variavel temp também. Vou procurar no google sobre o memset. O memset não é o mesmo que o free() ? falous
  24. Ouvi tantas vezes mais não sei oque é buffer ? Desculpe-me pela falta de conhecimento... falous
×
×
  • Criar Novo...