Hi deeee Ho again! ^_^

I was bugging you guys with my questions about creatin a class for handling files (to update my webpages). Well, I managed to create the class (class tiedosto), and implement most of the functions I needed in it

Now I'm building main to actually utilize the class, and to actually update the files...

In order to do that, I should create new tiedosto class object, corresponding to every single file of my pages. Constructor of my tiedosto-class takes paths and filenames as arguments. So I thought I'll do a txt file, containing paths and names of my files on separate lines, and then just make the program to read the paths and names from the file.

Well, I tried to create new objects in a for loop... But I have problems in understanding how pointers work.. My goal was to have an array which each cell holds one object (or pointer to object..), so I could use the array[i] when I refer to a certain file. Am I making myself clear? Well, as I told, I have problems in understanding how pointers work in such cases.. So all help would be appreciated I'll post the code I have managed to produce this far below...


Code:
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "tiedosto.h"

using namespace::std;

main(){
    char *pagenames[250]; //arrays for filenames
    char *paths[250]; //arrays for paths
    
    int i=0,number_of_pages=0,lkm=0;
    FILE *readindex; // stream to read pagenames and paths from indexfile
    
    readindex=fopen("kotisivindex.txt","r"); //opens indexfile for reading
    while(feof(readindex)==0){
        if(fgetc(readindex)=='\n'){  
        number_of_pages++;  //if character that was read is '\n', increases number_of_pages.
    }
    }
    number_of_pages=number_of_pages/2; //because theres path in 1st. line, and name of the file in 2nd line.
    fclose(readindex); 
    readindex=fopen("kotisivindex.txt","r"); 
    for(i=0;i<number_of_pages;i++){
        fgets(*paths[i],500,readindex); //stores paths in arrays
        fgets(*pagenames[i],500,readindex); //stores filenames in arrays
    
    tiedosto *pagefiles[i] = new tiedosto(pagenames[i],paths[i]); /*creates new object.
    constructor is "tiedosto(char filename[],char path[]); So pagenames and paths should be given 
    as char arrays.*/
    
    //ignore the rest, it I can make working on my own, and if I cant, then I'll ask again :p
    
        cout << "kasittelyssa " << (*pagefiles[i]).kokonimi << endl; 
        lkm=*pagefiles[i].lisaa_loppuun("</LI>","\n");
        cout << "</LI> " << lkm << " kappaletta" << endl;
        lkm=*pagefiles[i].lisaa_loppuun("</UL>","\n");
        cout << "</UL> " << lkm << " kappaletta" << endl;
        lkm=*pagefiles[i].lisaa_loppuun("-->","\n");
        cout << "--> " << lkm << " kappaletta" << endl;
        lkm=*pagefiles[i].lisaa_loppuun("<TR>","\n");    
        cout << "<TR> " << lkm << " kappaletta" << endl;
        lkm=*pagefiles[i].lisaa_loppuun("<TD>","\n");
        cout << "<TD> " << lkm << " kappaletta" << endl;
        lkm=*pagefiles[i].lisaa_loppuun("</TR>","\n");
        cout << "</TR> " << lkm << " kappaletta" << endl;
        lkm=*pagefiles[i].lisaa_loppuun("</TD>","\n");
        cout << "</TD> " << lkm << " kappaletta" << endl;
        lkm=*pagefiles[i].lisaa_loppuun("<TABLE>","\n");
        cout << "<TABLE> " << lkm << " kappaletta" << endl;
        lkm=*pagefiles[i].lisaa_loppuun("</TABLE>","\n");
        cout << "</TABLE> " << lkm << " kappaletta" << endl;
    }
}