file opening/checking file

allright this is my pseudo code i was trying to write in c++. As most of you probably noticed im a c style coder but im learning c++ step by step

what im trying to write is a function that will open a file named init.conf and read the list of files that are located in the init.conf file and check if it exists and if it does to see its size


if you try this pseudo function i get the output "could not read files in init.conf". I've tried going to freenodes general c++ irc chatroom and they told me the code is horribly written and there are some details that are useless

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    char config_init(char config_list[25][50]){
            int n = 0;
            long begin,end, totes;
            string file;
            char file_foo[50];
            ifstream config("init.conf");
            if(config.is_open()){
                    while(config.good()){
                            getline(config, file);
                            for(int i = 0; i > 50; i++){
                                    file[i] = config_list[n][i];
                                    file[i] = file_foo[i];
                            }
                    ifstream funcobj(file_foo);
                    if(funcobj.is_open()){
                            begin = funcobj.tellg();
                            funcobj.seekg(0, ios::end);
                            end = funcobj.tellg();
                            totes = end - begin;
                            cout << file << " is: " << totes << " bytes\n";
                            funcobj.close();
                            }
                    else{
                            cout << "could not read files in init.conf";
                            exit(0);
                            }
                    n++;
                    }
                    config.close();
            }
            else{
                    cout << "could not open init.conf";
                    exit(0);
                    }
            return config_list[25][50];
    }
Last edited on
bump
Please, don't double post -> http://cplusplus.com/forum/beginner/98029/
reply made to other thread
Topic archived. No new replies allowed.