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
You should use std::string instead of char arrays. Also, confing_list should probably
be a std::vector < std::string >. Another good idea is to break the task in smaller parts.
Write a function that checks whether a file exists or not. Then, write a function that returns
the size of an existing file. Then, use these two to implement your config_init function.
getline(config, file);
for (int i = 0; i > 50; i++)
{
file[i] = config_list[n][i];
file[i] = file_foo[i];
}
a line is read from the file config into the string file.
and then what... well I was going to say the string is immediately over-written with some other data.
But in fact, the condition i > 50; will be false, so the loop does not execute.
After that, this line, ifstream funcobj(file_foo); attempts to open the file named file_foo - which is just an uninitialised array of characters, containing any garbage data.