tiag0 Posted December 7, 2009 at 02:51 PM Report Share #299061 Posted December 7, 2009 at 02:51 PM Bem, eu teria que usar o 'vector de strings'. o programa le o ficheiro base e depois como cada string esta dividida por virgulas devia copiar cada ate cada virgula e imprimir no novo ficheiro criado. (para isso tenho que criar uma variavel para cada string) é isto que nao sei programar. a funçao que uso para criar o ficheiro e: FILE *file = fopen #include <stdio.h> #include <stdlib.h> const int TAM_BUFFER = 255; // quantidade de caracteres a serem lidos no buffer de cada vez int main(int argc, char *argv[]) { FILE *arquivo = fopen("nomes.txt", "r"); char buffer[TAM_BUFFER]; // testa se o arquivo foi aberto com sucesso if(arquivo != NULL){ // ler o conteúdo do arquivo e armazenar no buffer while(fgets(buffer, TAM_BUFFER, arquivo)){ //ler palavra a palavra char *token = NULL; token= strtok(buffer, "," ); while( token ) { printf("%s\n",token); token = strtok( NULL, "," ); } } fclose(arquivo); } else printf("Nao foi possivel abrir o arquivo."); printf("\n\n"); system("PAUSE"); return 0; } Link to comment Share on other sites More sharing options...
tiag0 Posted December 7, 2009 at 02:52 PM Author Report Share #299062 Posted December 7, 2009 at 02:52 PM Em seguimento a ultima mensagem.. duvidas a programar em C. agradeço a ajuda. obrigado Link to comment Share on other sites More sharing options...
Baderous Posted December 8, 2009 at 02:22 PM Report Share #299244 Posted December 8, 2009 at 02:22 PM Não cries tópicos repetidos. http://www.portugal-a-programar.pt/index.php?showtopic=30946 Link to comment Share on other sites More sharing options...
TheDark Posted December 8, 2009 at 06:39 PM Report Share #299319 Posted December 8, 2009 at 06:39 PM Discussão continua no tópico indicado pelo Baderous. Desaparecido. Link to comment Share on other sites More sharing options...
Recommended Posts