|
|
|
|
Posté par
k11, le mardi 17 avril 2007 à 08:43:21
#include <stdio.h>
#include <stdlib.h>
typedef struct field field;
struct field
{
char Engl[100];
char Acro[100];
char Jp[100];
char exp[100];
};
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include<string.h>
#include "main.h"
int main(int argc, char *argv[])
{
char ACR[3]={97,34,62}; //code ascii for | a">
char ENG1[3]={119,34,62};//code ascii for | w"> | .....< :english
int CurrentChar;
int Cursor_position=0;
int i,j,k,f=0;
int expr_nbr=100;
field Field[expr_nbr];
int *buffer=NULL;
int CATEGORY[9]={67,65,84,69,71,79,82,89,91};// to detect the string"CATEGORY["
char FileName[100];
char CAT[100];
for(i=0;i<100;i++) {
Field[i]=(malloc(sizeof(field));
}
FILE *TheFile=NULL; //the readed file
//to open the 9 files
for(f=1;f<10;f++)
{//accolade pr faire ca pour les 9 fichiers
sprintf(FileName,"%d.htm",f);
TheFile = fopen(FileName, "r");
if(NULL==TheFile){
printf("ERROR!This File does not exist!!\n\n");
return 1;}
if (TheFile!= NULL)
{
// scanning all the character of the text
do
{
CurrentChar = fgetc(TheFile );
for(i=0;i<9;i++)
{
if(CATEGORY[i]==CurrentChar)
Cursor_position++;
}
i=0;
do{ //fill the array category with the name of the category
CAT[i]= CurrentChar;
i++; }
while(CurrentChar=!60);
rewind(TheFile);//place the cursor to the beginning of the File
//& continue scanning
for(i=0;i<3;i++)
{
if(CurrentChar==ENG1[i])//when I found the string<span class="a"> I began
//to move the cursor until the english sentence
{ Cursor_position++;}
}
k=0;
do{
Field[expr_nbr].Engl[k]=CurrentChar;//input english words in the english string
k++; //move the index in the string to scan the next char
}
while(CurrentChar=!60) ;//then scan every char until "<"
for(i=0;i<3;i++)
{
if(CurrentChar==ACR[i])
{Cursor_position++;}
}
if(ACR[i+1]==62)
{
//if we don't have acronym:in this situation
//span class= "a">< input the japanese sentence
for(i=0;i<6;i++) {
*buffer=CurrentChar;//to move the cursor of 6 until
//the begining of jp sentence </span>
}
k=0;
do{
Field[expr_nbr].Jp[k]=CurrentChar;
k++;
}
while(CurrentChar=!60) ;
buffer=NULL;//initialize the buffer again
}
else {
//input the ACRONYM and then input the japanese sentence
do
{
k=0;
Field[expr_nbr].Acro[k]=CurrentChar;//input Acronym in the ACRO string
k++; //move the index in the string to scan the next char
} while(CurrentChar=!60); //then scan every char until "<"
do{
for(i=0;i<10;i++)
{
*buffer=CurrentChar;// </span><br> after these 10 char &stock
k=0;
Field[expr_nbr].Jp[k]=CurrentChar;
k++;
}
}
while(CurrentChar=!60); //japanese
}
buffer=NULL;
}//fin du do
while (CurrentChar != EOF);
//display data as tabulated file
for(i=0;i<expr_nbr;i++)
printf("%s \n\n\n %s \t\t %s \t\t %s \t\t %s\n ",CAT,Field[expr_nbr].Engl,Field[expr_nbr].Acro,Field[expr_nbr].Jp,Field[expr_nbr].exp);
fclose(TheFile);
}
//if open
}//9 files
system("PAUSE");
return 0;
}//accolade du main
Configuration: Windows XP Internet Explorer 6.0
Salut,
Mets const int expr_nbr=100; dans ta déclaration au lieu d'un int expr_nbr=100; Normalement ça sera déjà mieux. Tiens moi au courant Qui n'a rien n'a rien (Proverbe Norvillois)
|
Si j'ai bien compris ton code, tu prends un caractère dans le fichier, tu le scan un coup pour voir si ça fait le bonne chaîne, et tu positionnes un curseur position au bon endroit dans le fichier ? (cursor_position pointe sur le fichier ?)
Seulement après, tu ne tiens plus compte de ce curseur, tu copies tout dans CAT[i] jusqu'à ton caractère '<' quoiqu'il arrive. En plus ça se brouille ici, tu copies currentchar dans le 2e do/while en incrémentant CAT[i], mais sans changer currentchar. Enfin tu as une accolade ouvrante toute seule (ligne 4), peut-être n'as-tu pas mis tout ton code, et avec ce que je lis je ne peux pas t'aider plus voilà ! Bon courage Qui n'a rien n'a rien (Proverbe Norvillois)
|
Le problème c'est que j'ai l'impression que ta condition
if(CurrentChar==ENG1[i])ne sert à rien. Si c'est le premier ou le deuxième, bah c'est bloqué au if suivant, du coup ça reboucle comme si il n'y avait rien, tu as un donc un test unique sur le dernier caractère (le 3e). Pourquoi ne fais-tu pas un fgets ainsi tu pourrais scanner une chaine de caractère ça serait plus simple non ? Qui n'a rien n'a rien (Proverbe Norvillois) |
| 15/03 20h06 | Import / export de données Ingres | Ingres |
| 10/04 20h18 | Structure logique d'un disque dur | Disque dur |
| 29/07 12h05 | GRUB - La structure de fichier de configuration | Linux |
| 29/10 12h46 | Trier un tableau sans utiliser la fonction sort | Perl |
| 11/01 11h08 | Décaler les éléments d'un tableau (Rotation) -Récursivité- | Pascal |
| 24/04 13h37 | [VB.NET] Probleme Tableau structure | 6 |
| 13/03 23h38 | [C] Allocation dynamique - Tableau et structu | 4 |
| 17/11 19h13 | [C]Passage de tableau de structures ds 1 fctn | 13 |
| 31/10 12h49 | Export structure table access sous forme SQL | 4 |
![]() | Tables multimédia - En général les enfants ont tendance à ne pas vouloir étudier et les parents perdent parfois patience à leur apprendre. Peut... | Catégorie: Bureautique Licence: Freeware/gratuit |
![]() | OpenOffice.org - OpenOffice est une suite bureautique complète entièrement gratuite, compatible avec la suite Microsoft Office. Elle... | Catégorie: Suite bureautique Licence: Open Source |
![]() | Open Workbench - Open Workbench est une application libre de gestion et de planification de projet. Il s'agit d'un équivalent libre de... | Catégorie: Gestion de projet Licence: Open Source |
![]() | MediaInfo - MediaInfo fournit la liste des codecs nécessaires ainsi que des informations techniques sur vos fichiers vidéo et audio. ... | Catégorie: Codecs Licence: Open Source |
![]() | Lenovo X60Tablet Intel Core | Catégorie: Tablet PC | |
![]() | Samsung Q1b HSDPA VIA | Catégorie: Tablet PC | 1,145.50 € MicroChoix |
![]() | Samsung Q1U-CMXP Intel A110 | Catégorie: Tablet PC | 1,192.90 € MicroChoix |
![]() | Samsung Q1 Ultra WIP | Catégorie: Tablet PC | 955.60 € Misco FR |