
fgs4ntos
(usa Ubuntu)
Enviado em 18/04/2012 - 10:36h
ThePinkShark muito obrigado pela atenção, meu amigo de me deu um toque de como seria feito é ficou assim.
////////////////////////////////////ler_arquivo_ponto_a_ponto///////////////////////////////
int ler_arquivo_ponto_a_ponto(){
FILE *arquivo;
char nome[30], string[100], aux[100];
/*char delimita_inicio[], delimita_fim[];*/
int n_elementos=0, c, pos_aux=0;
//printf("Digite o nome do arquivo: ");
//gets(nome);
arquivo = fopen("untitled.x3d", "r");
/*if (arquivo == NULL)
{
printf("Erro ao abrir o arquivo: %s", nome);
getch();
return 1;
}*/
printf("\nConteudo do arquivo:\n");
//while ( (c = getc(arquivo)) != EOF )
//printf("%c",c);
while ( !feof(arquivo) )
{
fscanf(arquivo,"%s",string);
if ( strcmp(string,"<IndexedFaceSet") == 0 )
{
while (strcmp(string,">") !=0 )
{
fscanf(arquivo,"%s",string);
for (c = 0; c < strlen(string); c++)
{
if ( isdigit(string[c]) || string[c] == 45 )
{
aux[pos_aux] = string[c];
pos_aux++;
}
aux[pos_aux] = '{TTEXTO}';
}
pos_aux = 0;
if (strlen(aux) > 0)
{
printf("%d: %s\n", n_elementos, aux);
n_elementos++;
}
}
//printf("\n\n%d elementos.\n\n",n_elementos);
n_elementos = 0;
}
else
if ( strcmp(string,"<Coordinate") == 0 )
{
while (strcmp(string,"/>") !=0 )
{
fscanf(arquivo,"%s",string);
for (c = 0; c < strlen(string); c++)
{
if ( isdigit(string[c]) || string[c] == 45 || string[c] == 46)
{
aux[pos_aux] = string[c];
pos_aux++;
}
aux[pos_aux] = '{TTEXTO}';
}
pos_aux = 0;
if (strlen(aux) > 0)
{
printf("%d: %s\n", n_elementos, aux);
n_elementos++;
}
}
//printf("\n\n%d elementos.",n_elementos);
n_elementos = 0;
}
}
fclose(arquivo);
return 0;
}
//////////////////////Fim funcao ler_arquivo_ponto_a_ponto /////////////////////////
Dei uma olhada na sua dica tbm, valeu.