Article View: be.comp.programming
Article #15975Re: windows trager t.o.v. linux?
From: Thunderbird
Date: Thu, 06 Jul 2000 00:00
Date: Thu, 06 Jul 2000 00:00
74 lines
2908 bytes
2908 bytes
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
void main ()
{
//************declaraties***********************
string tempstring, te_zoeken,stringbuffer;
char bestandsnaam [75],schrijfnaar[75],x,buffer [10000],inlezen;
int aantal=0,atl_lijn_teller=0;
long tijd;
FILE * inleesbestand;
FILE * resultaatbestand;
cout<<"Geef de directory en de bestandsnaam in van het bestand: ";
cin>>bestandsnaam;
//***********inputcontrole***********************
while ((inleesbestand = fopen (bestandsnaam, "r")) == NULL)
{
cout<<"Sorry, het opgegeven bestand kan niet gevonden worden"<<endl;
cout<<"Geef opnieuw je bestandsnaam op: " ;
cin>>bestandsnaam;
}
cout<<"Geef op waarnaar het programma moet zoeken: \n";
getline(cin,te_zoeken);
cout<<"naar welk bestand moet geschreven worden?: \n";
cin>>schrijfnaar;
//**************start tijdsopname na correcte invoer***********************
tijd=time(0);
cout<<"Bezig met verwerken van het bestand..."<<endl;
//*************verwerking van het aantal karakters***********************
inleesbestand = fopen (bestandsnaam, "r");
for ( ;getc (inleesbestand) != EOF; aantal++);
fclose (inleesbestand);
//*************opzoeken van de string**********************************
int teller=0;
inleesbestand = fopen (bestandsnaam, "r");
FILE *output= fopen(schrijfnaar, "w");
char zinneke[1000];
while (fgets(zinneke,10000, inleesbestand))
{ string stringzinneke;
atl_lijn_teller++; //verwerking atl lijnen
for(int x=0; x<1000 && zinneke[x]!='\n';x++)
{
stringzinneke= stringzinneke+ zinneke[x];
}
if(stringzinneke.find(te_zoeken) != -1)
{
stringzinneke.append(1,'\n');
fwrite(zinneke,stringzinneke.length(),1,output);
teller++;
}
}
fclose(inleesbestand);
fclose(output);
//****************uitvoer van de resultaten****************************
cout<< "Bestand verwerkt in "<<time(0)-tijd<<" seconden \n";
cout<<"Het bestand "<<bestandsnaam<<" bevat "<<aantal<<" karakters en "<<atl_lijn_teller<<" lijnen"<<endl;
cout<<te_zoeken<<" komt in "<<teller<<" zinnen voor"<<endl;
In article <3964AE88.672E6219@get.be>, Ronny Dierckx <dr@get.be> wrote:
Technical Details
Message-ID:
<61495.10471$Ud2.169488@afrodite.telenet-ops.be>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<oi_85.3142$Ud2.44517@afrodite.telenet-ops.be> <3964AE88.672E6219@get.be>Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit X-Google-Thread: fcea4,b9f6caafd8dd067a X-Google-Attributes: gidfcea4,public From: "Thunderbird" <goeroe@hotmail.com> Subject: Re: windows trager t.o.v. linux? Date: 2000/07/06 Message-ID: <61495.10471$Ud2.169488@afrodite.telenet-ops.be> X-Deja-AN: 643147155 References: <oi_85.3142$Ud2.44517@afrodite.telenet-ops.be> <3964AE88.672E6219@get.be> X-Trace: afrodite.telenet-ops.be 962907330 212.123.13.235 (Thu, 06 Jul 2000 20:15:30 MET DST) Organization: Pandora - Met vlotte tred op Internet NNTP-Posting-Date: Thu, 06 Jul 2000 20:15:30 MET DST Newsgroups: be.comp.programming