Ir ao conteúdo

Lista com ponteiros, Estrutura de Dados.

Boa noite a todos,

Como ainda não produzi nada muito bom hoje em casa (no lab produzi algo relaciona a xml-rpc que pretendo postar em breve), resolvi postar mais um dos 198578951 exercicios que estou tendo que fazer para estrutura de dados. O Exercicio de hoje é nada mais nada menos que uma implementação de uma Lista com Ponteiros, ou seja, ela não tem limite de elementos (é claro, se a memoria for infinita).

Como no exercicio anterior, o enunciado fica para a pagina inteira pois é muito grande.

O exercicio resolvido você encontra aqui.

Uma lista ordenada pode conter Strings de qualquer comprimento < 10000; • esta lista tem um número de elementos máximo fixo (100) e é implementada como um vetor de ponteiros para Strings; – utilize as rotinas de lista com vetor que você implementou para a agenda. • Um novo String é lido primeiramente para dentro de uma variável auxiliar qualquer; – então é alocada memória para exatamente o seu tamanho e ele é copiado para esta área. Para copiar um String utilize strcpy(); – por fim um lugar na lista é encontrado para ele. A posição escolhida do vetor de ponteiros da lista é instanciada através da atualização dos valores do ponteiro da posição do String na lista com o endereço do string. Pseudo-código: constantes MAXLISTA = 100; tipo tLista { // Vetor de ponteiros para caracter. caracter *dados[MAXLISTA]; inteiro último; }; • Importante: observe que criando uma variável do tipo tLista você não vai estar alocando memória para os strings a serem lidos, apenas para os ponteiros para eles. Para verificar o comprimento de um String: – utilize a função strlen(); – esta função devolve o comprimento (em caracteres imprimíveis) de um string. – Protótipo: int strlen(char *p); #include
#include
#include
char p[90] = “Carro”;
main() {
printf(“%i”, strlen(p));
}

• Imprime: 5
• Para copiar um String:
– utilize a função strcpy();
– esta função copia o conteúdo de um string (dado por um apontador) para a posição de memória dada por outro apontador.
– Protótipo: char *strcpy(char *destino, char *fonte);

#include
#include
#include
char p[90] = “Carro”;
char lata[20];
main() {
strcpy(lata, p));
printf(“s%”, lata);
}
• Imprime: Carro

Detalhes:

• Como você não sabe o comprimento do String que o usuário vai digitar, use primeiro uma variável auxiliar grande (10000 posições) para guardar o que foi
digitado;
• todas as funções de lista ordenada implementadas anteriormente devem ser reimplementadas para utilizar estes Strings;
• para a leitura de um String utilize scanf(“%s”, entrada).

Publicado emAprendendoCEstrutura de DadosSistemas Digitais

1.832 Comentários

  1. Hello, I enjoy reading all of your article. I like to write a little comment to support you.

    Also visit my homepage :: webpage

  2. Hi there! This post couldn’t be written any better! Reading
    this post reminds me of my good old room mate!
    He always kept chatting about this. I will forward this
    article to him. Fairly certain he will have a
    good read. Thanks for sharing!

    my web blog: Basketball wm wetten (sitono.de)

  3. UAE Warriors 70
    This Friday, May 8, UAE Warriors 70 rolls into the Space42 Arena in Abu Dhabi featuring a card heavy on regional specialists and international veterans looking for a final push toward major promotions .

  4. Heya! I just wanted to ask if you ever have any problems with
    hackers? My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no
    data backup. Do you have any methods to prevent hackers?

    Feel free to visit my web site :: basketball tipps wetten (Mariel)

  5. http://exocet-web.fr/
    La societe Exocet Web se positionne comme une agence specialisee dediee au le cadre national francais, qui propose des services de qualite a ses clients, en valorisant sur l’excellence du service. En savoir plus sur cette page.

  6. ACA Young Eagles 64, which happens in mid-May 2026 stands as a classic illustration of a fight card where the popular narrative regularly fails to reflect the actual gap in capabilities, especially when looking at the developmental divisions of the Absolute Championship Akhmat .

  7. http://solicio.fr/
    La societe Solicio se presente comme une entreprise professionnelle orientee vers le tissu economique francais, qui met a disposition une approche complete aux entreprises et particuliers, en valorisant sur l’attention personnalisee. Visitez le site ici.

  8. http://bk-designs-gbr.de/
    Das Projekt Bk Designs Gbr positioniert sich als ein vertrauenswuerdiger Partner spezialisiert auf den nationalen Rahmen Deutschlands, das anbietet massgeschneiderte Loesungen fuer alle die Ergebnisse suchen, priorisierend auf persoenliche Betreuung. Mehr Informationen ueber den Link.

  9. http://marketingpeach.de/
    Das Unternehmen Marketingpeach etabliert sich als ein erfahrene Beratung ausgerichtet auf den nationalen Rahmen Deutschlands, das bereitstellt massgeschneiderte Loesungen fuer Unternehmen und Privatpersonen, sich auszeichnend durch auf Servicequalitaet. Erfahren Sie mehr auf dieser Seite.

  10. http://rothschild-kollegen.de/
    Das Team von Rothschild Kollegen ist ein vertrauenswuerdiger Partner spezialisiert auf den nationalen Rahmen Deutschlands, das anbietet hochwertige Dienstleistungen fuer Unternehmen und Privatpersonen, sich auszeichnend durch auf Ergebnisse. Erfahren Sie mehr auf dieser Seite.

  11. http://sol4bus.de/
    Sol4bus praesentiert sich als ein vertrauenswuerdiger Partner fokussiert auf den deutschen Markt, das anbietet professionelle Begleitung fuer Unternehmen und Privatpersonen, sich auszeichnend durch auf Ergebnisse. Mehr Informationen ueber den Link.

  12. http://webfrick.de/
    Das Projekt Webfrick etabliert sich als ein professionelles Unternehmen fokussiert auf das Publikum in Deutschland, das liefert ganzheitliche Ansaetze fuer seine Kunden, priorisierend auf Servicequalitaet. Erfahren Sie mehr hier.

  13. Whilst the casuals are glued to the UFC card on Saturday, we’re making our way to Foxwoods on Friday night to capitalize on several notable regional pricing discrepancies.

  14. Akçam Otel Programı: Kanal yönetimi, bulut tabanlı ön büro ve anlık raporlama özellikleriyle otelinizin tüm operasyonel süreçlerini tek bir escort platformdan verimli ve hatasız yönetmenizi sağlayan kapsamlı otomasyon çözümüdür. https://akcam.com.tr/assist.htm

  15. First off I would like to say superb blog! I had a quick question which I’d like to ask if
    you do not mind. I was curious to know how you center
    yourself and clear your head before writing.
    I have had trouble clearing my thoughts in getting my thoughts out.
    I do take pleasure in writing however it just seems like the first 10 to 15
    minutes are generally lost just trying to figure out how to begin. Any
    suggestions or hints? Cheers!

    my page; Wyniki meczów nba

  16. You are obviously very knowledgeable. This is an excellent, an eye-opener for sure! Great post! The really good news is that investing in this approach does not stop you from investing in the other. I tried more info. Thanks for writing this. Thumbs up! It’s like you read my thoughts! The really great news is that investing in one approach does not hinder you from trying the other. You appear to know a lot about this. You appear to know a lot about this. You appear to know a lot about this. Nice write up. Hit me up! You appear to know a lot about this. Your article has proven useful to me. Nice write up.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *