Ir ao conteúdo
  • Cadastre-se

cgm2k7

Membro Pleno
  • Posts

    38
  • Cadastrado em

  • Última visita

posts postados por cgm2k7

  1. valeu muito obrigado... por essa dica pois abriu mais minha mente, eu até já lir sobre isso não levei muito a serio, mas agora ficou mais claros soubre essa dicas de em c...

     

    MAs uma duvida: vir em alguns livros e apostilhas que retorna valor não é uma boa pratica de programação, porque usa mais processo e memoria porque ele faz uma segunda copia dos dados a serem retornado.

    Ou  neste caso retornando um endereço para uma dado "ponteiro" seria não run!

     

    Exemplo:

     

    int a = 100, b = 1000;

     

    int retorn_valor(int a, int b)

    {

        return a * b;

    }  

    neste caso ele faz uma copia na memoria a mais correto!?.

     

    e se for assim:

     

    int* retorn_valor(int *a, int *b)

    {

       return a * b;

    }

    neste caso é mais otimizado certo... porque não sera feita uma copia dos dados na memoria...

     

    agradeço mesmo pelas dicas minto obrigado...

  2. Boa noite!

    Bom preciso de uma dica/ajuda em uma problema...

    tenho duas structs, LIST e NO.  lista duplamente encadeada.

    //insiro/crio 100.000 nos.

     

    struct no{
        char *nome;
        char sexo;
        float nota;
        float media;
        int id;    
        struct no *next, *prev;
    };
    
    struct list{
        long int size_list;
        struct no *begin, *end;
    };
    
    typedef struct no NO;
    typedef struct list LIST;
    
    for(int y = 0; y < 100000; y++)
                inserir_inicio(*list); 
    
    void CreateNo(NO **no)
    {
        *no = (NO*)calloc(1,sizeof(NO));
    
        if (*no) {
            (*no)->nome = "cicero";
            (*no)->sexo = 'M';
            (*no)->nota = 0.0;
            (*no)->media = 1;
            (*no)->id++;
            (*no)->next = NULL;
            (*no)->prev = NULL;
    
            is_Ok = true;
        }
        else {
            printf("ERRO: Ao alocar memoria em 'void CreateNo(NO **no)'\n");
            is_Ok = false;
            return;
        }
    }
    
    void inserir_inicio(LIST *list)
    {
        NO *no;
        CreateNo(&no);
    
        if (is_Ok) {    
            no->next = list->begin;
            list->begin = no;
            list->size_list++;
        }
    }
    
    // destroy os nos
    void DestoyList(LIST **list)
    {
    	if ((*list)->begin == NULL)
    	{
    		free(*list);
    		printf("Lista vazia!\n\n");
    	}
    	else {
    		NO *p = (*list)->begin, *tmp = NULL;
    		
    		while (p != NULL) {			
    			tmp = p;
    			p = p->next;
    
    			/*tmp->nome = "0";
    			tmp->sexo = '\0';
    			tmp->id = 0;
    			tmp->media = 0;*/
    
    			free(tmp);
    		}
    		free(p);
    		(*list = NULL);		
    	}
    }

    o problema é o seguinte:

    quando inicio o aplicativo ele começão com 512kb, quando criando  100.000  na memoria heap, aumenta para mais ou menos uns 7,8mb, bom ate aqui tudo oks

    mas quando delete este nos com o free() esperava eu q retornasse para os mesmo 512kb inicias do aplicativo, mas isso não acontece, ele retorna para 1,3mb.

    minha pergunta é: porque não deleta tudo, já setei zeros e para todos os membros da struct no mas mesmo assim não deleta tudo.

    Se alguém poder meda da uma dica. OBS: não quero código  pronto eu quero apenas dicas se possível bem explicada porque sou meio novato em c kkk.

  3. Olá bom dia!

     

    Estou com uma dificuldade se alguém poder me ajudar agradeço:

    É o seguinte, tenho um arquivo de texto com as seguintes linhas:

    name=idle
    
    w=60
    
    h=105
    
    x=61.0f
    
    y=0.0f
    
    w=62
    
    h=100
    
    x=63.0f
    
    y=20.7f
    
    w=78
    
    h=89
    
    x=67.0f
    
    y=25.0f
    
    name=walk-back

     

    ..... e assim continua..

    A duvida é: como faço para pegar só os valores de name,w,h,x,y e jogar uma matriz ou vector?

  4. 9 horas atrás, vangodp disse:

    Não entendo

     

    acho que não expliquei o que queria direito kkkk, desculpas.. Vou tentar explicar mas simplesmente.
     

    if (currentFrame == 9){
    currentFrame = 0;
    // Qaundo o 'currentFrame == 1', execute uma ação somente uma vez
    // Neste loop o 1 é repetido 4 vezes, preciso que execute a ação somente no primeiro 1
    }else{
    if (slow == 4){
       currentFrame++;
       slow = 0;
     }
    slow++
    }

     

  5. olá boa noite a todos!

    Estou "tentando" desenvolver um jogo de luta em SDL2 c++,  estou com o seguinte problema:

    tenho um loop 10 posição sendo que cada posição repete 4 EXEMPLO:  na posição 0 repete 0 0 0 0 na posição 1 repete 1 1 1 1 e a sim por diante ate o numero 9,

    o que eu quero é que quando chegar em uma posição que eu escolher Exemplo: seu eu escolher a posição 1 execute uma ação mas somente o primeira vez que

    repetiu o numero 1 as outras vez que o numero 1 for repetido não execute nada.

    Não estou conseguindo resolver este problema não sei porque, sendo que já fiz coisa muito mais difícil e complexa que isso, acho que não to pensando direito kkkk.

    veja um exemplo de loop...  não este que estou usando não mais é parecido mesma logica.

      

    if (currentFrame == 9){

    currentFrame = 0;

    }else{

    if (slow == 4){

    currentFrame++; slow = 0;

    } slow++

    }

    • Curtir 1
  6. Muito obrigado a todos pela atenção..
    peguei uns pedaços de outros trabalhos meu e criei este código.

    mas tem um dois problema que não estou conseguido pesas direito de  onde esta o erro. Se alguém puder me ajudar...

    1ª: Não estou conseguido colocar no cabeçalho do arquivo.dat as informações das outras imagens só consigo da primeira...
    2ª: Alguma coisa esta modificado o conteúdos das outras imagens somente a primeira fica com os tamanho original.

     

    Veja abaixo meu código completos:

    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include <unistd.h>
    
    typedef unsigned char u8;
    typedef unsigned short u16;
    typedef unsigned int u32;
    
    u32 LE32(u32 b) {
        u32 t = 0x12345678;
        if (*((unsigned char*)(&t)) == 0x78) {
    	return b;
        } else {
    	return ((b & 0xff000000) >> 24) |
    	       ((b & 0x00ff0000) >> 8 ) |
    	       ((b & 0x0000ff00) << 8 ) |
    	       ((b & 0x000000ff) << 24);
        }
    }
    
    unsigned char dat_header[] = {
        0x7f,  'D',  'A',  'T', 0x00, 0x00, 0x00, 0x00,
    };
    
    void usage();
    void create_dat(FILE * dest, const unsigned char * source, u32 size, int three_argc);
    
    int main(int argc, char** argv)
    {    
        u32 fd_size, start = 0, end = 0xffffffff, size = 0xffffffff;
        unsigned char * buffer;
        FILE * source, * dest;
        char * f_source = 0, * f_dest = 0;
    
    	f_source = argv[1];
        f_dest   = argv[2]; 
        int quantity_of_items = atoi(argv[3]); //quantity of items
    
        if (!f_source || !f_dest) {
    	usage();
    	printf("Not enough arguments.\n");
    	return 1;
        }
    
        if (!(source = fopen(f_source, "rb"))) {
    	printf("Error opening %s for reading.\n", f_source);
    	return 1;
        }
    
        fseek(source, 0, SEEK_END);
        fd_size = ftell(source);
        fseek(source, start, SEEK_SET);
    
        if (fd_size < end)
    	end = fd_size;
    
        if (end < (size - start))
    	size = end - start;
     
        buffer = malloc(size);
        if (buffer == NULL) {
    	printf("Failed to allocate memory.\n");
    	return 1;
        }
    
        if (fread(buffer, 1, size, source) != size) {
    	printf("Failed to read file.\n");
    	return 1;
        }
        fclose(source);
    
    	if (access(f_dest, F_OK) != 0)
    	{	
        	if (!(dest = fopen(f_dest, "wb+"))) {
    			printf("Failed to open/create %s.\n", f_dest);
    			return 1;
            }
    	}else{
    		if (!(dest = fopen(f_dest, "a+"))) {
    			printf("Failed to open/create %s.\n", f_dest);
    			return 1;
    		}
    	} 
    
        create_dat(dest, buffer, size, quantity_of_items);
    
        fclose(dest);
        free(buffer);
    
        return 0;
    }
    
    void create_dat(FILE * dest, const unsigned char * source, u32 size, int three_argc)
    {    
        u32 data_size[4];
        int i;
        
        if(three_argc > 0){ //three argument = 1		
    		for (i = 0; i < sizeof(dat_header); i++) {
    			dat_header[4] = three_argc;	//quantity of items 		
    		fputc(dat_header[i], dest);
    		}	
    	}
    	
    	data_size[0] = LE32(size);
        data_size[1] = 0;
        data_size[2] = 0;
        data_size[3] = 0;
        fwrite(data_size, 4, 4, dest);
    
        fwrite(source, 1, size, dest);
    }
    
    void usage() {
        printf("Usage: create_dat.exe infile outfile.dat\n--------------------------\n");	  
    }

    Eu adiciono as imagens através de um arquivo.bat, assim:

    create_dat.exe file1.png myfile.dat 5
    create_dat.exe file2.png myfile.dat
    create_dat.exe file3.png myfile.dat
    create_dat.exe file4.png myfile.dat
    create_dat.exe file5.png myfile.dat

    somente o primeiro aquivo tem o argv[3];

    adicionado 0 minutos depois

    http://www.mediafire.com/file/u3gb1fx0fxn4rn1/data.rar/file

    • Curtir 1
    • Amei 1
  7. olá pessoal bon dia!

    Venho aqui mais uma vez pedir ajuda...

    Estou criando um projeto, que preciso criar uma criar um arquivo binário com varais imagens dentro desse arquivo,

    e no cabeçalho desse arquivo  tem que informar o tamanho de o inicio e fim de cada imagem.

    Exemplo de como ficaria o arquivo em hex:  89 44 41 54 87 22 00 00 3D 67 00 00 2C 89 00 00

    os 1ª 4 caracteres seria o extensão  do arquivo ".DAT" os 4 próximos seria o tamanho da imagem, e os 4 próximos seria

    o ponteiro de inicio da imagem, e os 4 próximo seria  o ponteiro do fim da imagem...

    E assim com todas as imagens dentro desse arquivo.DATA

     

    https://ibb.co/ghj1WK

    https://www.imagemhost.com.br/image/2jf0B

    se alguém poder me ajuda desde já agradeço...

    • Amei 1
  8. Olá galera, pesquisei e tentei mas não tenho ideia de como fazer isso.

    Bom primeiramente deixe eu explicar...

    to com muitos videos aqui, todos com os nomes corretos, porém queria adicionar uma sequência numérica neles sem alterar o nome deles, sem substituir.

    Para simplificar, não ligo qual vai ser a sequencia, só preciso adicionar uma sequência mesmo.

    exemplo:

    nomes dos arquivos:

    video de testes.avi

    Video de mouse.avi

    video XXX.avi

    queria que ficasse assim:

    01 video de testes.avi

    02 Video de mouse.avi

    03 video XXX.avi

    Sei que poderia fazer isso manualmente, mais é sério preciso fazer isso em mais de 500 videos, não tem algum jeito mais fácil?

    Não ligo para a sequência nem nada...

    Eae galera vocês podem me ajudar?

    Desde já agradeço

    usa este programinha que eu fiz em delphi

    http://www.megaupload.com/?d=T04EP22C

    image.png

    wordpress image hosting

  9. ai é o seguine estou ingresando nessa de tradução de games.

    Eu uso o WinHex 14

    estou traduzindo no momento Tomb Raider UnderWorld pc

    já traduzi Tomb Raider Anniversary pc http://rapidshare.com/files/101456616/Tradu__o_Tomb_Raider_Anniversary_pc.rar

    o que quero é se alguem poder me ajudar ou me indicar onde posso encotra,

    é colocar acentos e tambem amentar o espaço para caber a palavra toda quando traduzida EX: se traduzir a

    palavra LOAD ficaria maior "CARREGAR" não vai caber no lugar da mesma palavra,

    no tomb raider que traduzir coloquei assim "CAR."

    e nos acento como não aseitava colocar o acento na maneira normal coloquei assim antes cada

    acento ou ç eu colocava esta letra em maisculo "Ã" EX: OPÃÇÃÃO no ficou assim OPÇÂO

    nos outros acentos a mesma coisa

    se alguem pode me ajudar desde já agradeço.

  10. Estou disponibilizando aqui tembem neste forum para download

    um patch para traduzir Tomb Raider Anniversary pc para português brasil

    http://www.4shared.com/file/41542995/d2fa0c8a/Traduo_Tomb_Raider_Anniversary_pc.html

    ou

    http://rapidshare.com/files/101456616/Tradu__o_Tomb_Raider_Anniversary_pc.rar

    traduolu7.jpg

    Leia o tutoria de instalação com atenção

    #############################################################################

    ########Tutorial-Instalar a tradução===95%_em português Brasil###############

    ##########Tomb Raider: Anniversary#################PC########################

    #############################################################################

    1º Copie a pasta "patch" e os 2 arquivo "aplicar e ApplyPPf3" que estão juntos no

    aquivo Winrar 'Tradução_Tomb_Raider:_Anniversary_pc.rar' que você baixou, para a pasta onde o

    jogo Tomb Raider: Anniversary está instalado. OBS: é a pasta do jogo onde se encontra os arquivos

    bigfile.003, bigfile.008, bigfile.012, bigfile.013, bigfile.014, bigfile.015, bigfile.016, bigfile.017,

    bigfile.018, bigfile.019, bigfile.021, bigfile.022 e o bigfile.023.

    2º Execute o arquivo "Aplicar" esper mais ou menos 10 segundos, ai está pronto é só jogar e se divertir

    com Tomb Raider: Anniversary 95% em português Brasil....

    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

    $$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$

    $$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$

    $$$$$$$$$$$$$$$$ Traduzido para o Português Brasil $$$$$$$$$$$$$$$$$

    $$$$$$$$$$$$$$$$ por by CgM2k8 $$$$$$$$$$$$$$$$$

    $$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$

    $$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$

    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

    [email protected]

  11. Ai pessoal sou novo aqui no forum

    estou pedindo ajuda.

    Estou traduzindo "tomb raider anniversary" de PC e PS2, tirei todo o texto em inglês das FMV(animações) do jogo

    estou pedindo que alguem traduza para mim. Não entendo nada de inglês, tenho um programa que traduz mas ele traduz

    muito ao pé da letra, ou seja fica sem sentido.

    se alguem poder traduzir o texto para min agradeço.

    Quando eu terminar de trazur tudo criarei um patch e colocarei aqui no forum para downloads.

    Veja o Texto(70% de todo o jogo)

    1

    What's a man got to do to get that sort of attention from you?

    If that's the sort of attention you want, Larson, you're well on your way.

    Sounds like fun, but I'm only here to make an introduction.

    Lara Croft, meet Jacqueline Natla, of Natla Technologies.

    Good afternoon, Miss Croft.

    My research department has recently turned its focus to the study of

    ancient artifacts.

    And I'm led to believe that, with the right incentive,

    you're just the woman to find them for me.

    I'm afraid you've been misled. I only play for sport.

    Which is precisely why I've to you, Miss Croft.

    This is game you've played before; with your Father.

    You both spent years searching for the Scion of Atlantis.

    All you needed was the location of Qualopec's Tomb.

    you've found Vilcabamba?

    How quickly can you get to Peru?

    2

    Vilcabamba continues to elude us,

    and my insistence that we press on

    in spite of these failures has morale low...

    I suspect Jenkins to be autor of this seditions;

    he simply refuses to accept the possibility tha atlantis is the foundation

    upon which all known civilizations were built.

    Increasingly, I find it is Lara alone

    who remains untainted by academic dogma

    and open-minded engough to see this truth.

    I'm sorry; I didn't bring enough rope.

    Not to worry. I'II find another way up.

    3

    There you are. Look, we have arrived.

    I don't know to open it.

    There's an inscription above the door.

    I'm very tired.

    We can got to the left.

    I´m only the guide.

    4

    Here sits the God-King Qualopec;

    One of the Triumvirate; Keepers of the Theree pieces of the Scion;

    Diviners of its knowledge; Sacred rulers of Alantis.

    5

    I'd love to join you, but I forgot my trunks.

    Why am I not surprised?

    You've got your job; I've got mine. I'II take it from here.

    I hope Natla sent you here with more that shotgun.

    Don't sweat it, kitten; I prefer a more hands-on approach.

    This is only one piece of the Scion; Where's the rest of it?

    Gimme a minute, I'm thinking.

    Whoa! It makes no difference to me:

    Pierre's probably already found his piece.

    Pierre Dupont? Where?

    Now that I don't know.

    All right. I'm convinced.

    Damn, you really had me going there.

    6

    Looks like our girl's pulled it off.

    Of course she has. Now it's up to you.

    Not that I'm complaining boss, but what makes you so sure

    she's not going to bring it back herself?

    Lara would never part with the Scion; she's far too obsessed with it.

    Just like her father.

    ah, Monsieur Dupont, you have something to report?

    Good news, Madame, your information was correct.

    I have located my piece of Scion.

    Voilà. It is buried under a place called

    7

    I've acquired new evidence that leads me to believe it is the Scion itself

    that is in some strange way, a vast library of information

    to rival even Alexandria.

    I am now convinced that, if I can obtain it,

    I will finally discover what happened to my beloved Amelia.

    Oh, Pierre, you litter bug.

    8

    I suppose you're more of a dog person.

    Natla doesn't honor her contracts, Pierre..

    I'd more on if I were you.

    No, mademoiselle, Natla and I understand each other. I find things for her

    and she rewards me handsomely.

    But you seek the very thing she does.

    That is why you are not trusted.

    I trust my instincts.

    And that is why you're in second place.

    I am a professional, mademoiselle.

    I focus on the job, and I get paid.

    There's more to life than money, Pierre.

    This isn't life, mademoiselle, it's business.

    Your compulsion prevents you from seeing the difference.

    It hasn't prevented me from getting a piece of the Scion. How's business

    for you?

    So then, why don't we see whose compulsion gets them the next piece.

    9

    Here lies the God-King Tihocan; One of the Triumvirate; Keepers of the

    Three Pieces of the Scon;

    Leader the chosen after the great betrayal

    caused Atlantis to be lost beneath the waves

    You see? Instincts can be expensive, madamoiselle.

    Yours are going to cost you both pieces of the Scion.

    That's not a price I'm prepared to pay.

    Don't be absurd. No job is worth dying for.

    Yes. It is.

    On second thought, you have it!

    Bonne chance!

    10

    You have tainted the power of the Scon;

    In betraying your feloow Kings

    you have broken the sacred Triumvirate of Atlantis.

    You have maimed Qualopec.

    Your own brother.

    I am still here, wretch. Tihocan has ended your treachery.

    But it is my face you will see in your nightmares.

    What have you to say for yourself?

    11

    Sorry, daelin'. This is the end of line.

    Just hand it over, Larson. This has nothig to do with you.

    What's it got to do with you? This Scion belong to Natla;

    Face it, you no business here.

    I don't have time for this. Get out of the way or you die.

    What you gonna do, shoot me? C'mon, Lara; I just work here.

    Now I know how bad you want this, but I can't let you pass.

    And we both know you're not gonna kill me for it.

    That's just not who you are.

    I'm not who you think I am.

    12

    I was hoping you'd show up; I want to make you scream.

    Unless you want to end up like Larson, get out of my way.

    It's so good, isn't it? It gets even better.

    You can't explain it to people; they have to feel it.

    Girl, you gotta be out of you mind!

    13

    Talk about being your own worst enemy.

    14

    You've reached the top, Lara. There's nowhere left to go but down.

    You're rebuilding the army of Atlantis.

    This Pyramid breeds far more than the the soldiers you've faced.

    With the Scion, I now heve the means to create anything I desire.

    What is it you desire, Natla?

    It takes Three to rule.

    Tihocan and Qualopec were too weak

    to destroy what stands in the way of the Seventh Age.

    But you have the strength to claim ths sat beside me.

    Immortality has its price.

    But what are a few livres to sacrifice for your dreams?

    This is madness.

    This is what you've been searching for.

    The answers you've sought your entire life ara within the Scion;

    everything you've done has led you to this place.

    You'e here because your belong here, Lara.

    That's who you are.

    I'm sorry, Father.

    15 = Final

    Thousands of years I've waited for this moment!

    Do you realize what you've done?

    That blood your hands, do you believe it was spilled for the good of all

    man,

    or for your own selfinsh desire? Look inside yourself, Lara.

    Your heart is as black as mine.

    I cannot die, you fool.

    Sooner or later, you'll run out of bullets.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!