Saving inputfrom textfile to array element

1
2
3
4
5
6
7
8
9
10
char sisend_rida[100];
    char andmebaas [100];
    ifstream fin("andmebaas.txt");
    // Andmete lugemine jadasse
    for(int i = 0; i <= 100 && ! fin.eof(); i++){
          fin.getline(sisend_rida,100);
          andmebaas[i] = sisend_rida;
          }
    for(int i = 0; i <= 100; i++){
            sisend_rida = andmebaas[i];

I have a text file with some data in it. But i want it to read 1 line of data into 1 array element. Example. adnmebaas[0] = 1 line from the andmebaas.txt.
How to do it. I know that this is possible andmebaas[1] = "Tere", but i need to get it from a text file, into array. After the text file has been but itnot the array, i need to do the opposite, but with a difference. sisend_rida = andmebaas[1], basiclly i give sisend_rida the value it gave to andmebaas[1] before, but this time, after valu has bene given, i shall analyse it. If this was but too long on hard to understand il write down individual steps i need.
1)Read one line from text file to 1 array slot.
2)line stored in 1 array slot will be given back to sisend_rida.
Total of 16 lines, mean i want to use only 16 array slots.
Anyone??

I would suggest Using a string array since a char array will only store one char in one slot. For example "Word" char array[0] = 'W' but if its a string it would be string array[0] = "Word"
Im trieing to help my friend with similar problem. Only difference is that he is using c language, so he cant use strings. i tohught that maybe andmebaa[50][100] somehow here you could read entire lines in.
Topic archived. No new replies allowed.