sonique
10-10-2007, 11:34
Ciao a tutti,
vi posto questo codice davvero banale:
#include <stdio.h>
#include <stdlib.h>
main()
{
FILE *fp, *fpTS, *fpVS, *fpts;
char string_name[27];
int ch = 1;
fp = fopen("total_test.txt", "r+");
fpTS = fopen("TS.txt", "w+");
fpVS = fopen("VS.txt", "w+");
fpts = fopen("ts.txt", "w+");
if (fp == NULL || fpTS == NULL || fpVS == NULL || fpts == NULL){
printf("\nOpen Error\n");
getch();
exit(1);}
// Vi sono 699 patterns - si usino: 233 pattern per il TS, 233 per il VS e 233 per il Test Set
//while(!feof(fp)){
while(ch <=699){
fscanf(fp, "%s", string_name);
printf("%s\n", string_name);
printf("%d\n", ch);
if(ch>=1 && ch<=233)
fprintf(fpTS, "%s\n", string_name);
if(ch>=234 && ch <=466)
fprintf(fpVS, "%s\n", string_name);
if(ch >= 467 && ch <=699)
fprintf(fpts, "%s\n", string_name);
ch ++;
}
fclose(fp);
fclose(fpVS);
fclose(fpts);
printf("\nLetti %d pattern: ", --ch);
getch();
}
Mi sapete spiegare perche non ne vuole sapere di scrivere nel file ts.txt? Mi va in crash l'eseguibile.
vi posto questo codice davvero banale:
#include <stdio.h>
#include <stdlib.h>
main()
{
FILE *fp, *fpTS, *fpVS, *fpts;
char string_name[27];
int ch = 1;
fp = fopen("total_test.txt", "r+");
fpTS = fopen("TS.txt", "w+");
fpVS = fopen("VS.txt", "w+");
fpts = fopen("ts.txt", "w+");
if (fp == NULL || fpTS == NULL || fpVS == NULL || fpts == NULL){
printf("\nOpen Error\n");
getch();
exit(1);}
// Vi sono 699 patterns - si usino: 233 pattern per il TS, 233 per il VS e 233 per il Test Set
//while(!feof(fp)){
while(ch <=699){
fscanf(fp, "%s", string_name);
printf("%s\n", string_name);
printf("%d\n", ch);
if(ch>=1 && ch<=233)
fprintf(fpTS, "%s\n", string_name);
if(ch>=234 && ch <=466)
fprintf(fpVS, "%s\n", string_name);
if(ch >= 467 && ch <=699)
fprintf(fpts, "%s\n", string_name);
ch ++;
}
fclose(fp);
fclose(fpVS);
fclose(fpts);
printf("\nLetti %d pattern: ", --ch);
getch();
}
Mi sapete spiegare perche non ne vuole sapere di scrivere nel file ts.txt? Mi va in crash l'eseguibile.