Hello,

i wan to do c++ program in ubuntu that able to write a summary on the directory example is

drwx-x John 4096
d-w--x John 14
lrwx-x John 2300

How to i use array to put per column into array then access them so i can generate a report so it will be like this

Summary
Total directories = 2 ( the number of d in front determine it)
total link files = 1 ( the number of l in front determine it)
Name of user = John
Total size = 6410 (the total size of last column)

for now is i using char to determine the directories and link file

int main()
{
char input[100]
int directory = 0;

while(cin>>input)
{
if(input[0] == 'd')
directory++;
}
cout<<dir<<endl;
}

this is what i done to find the directories and link, but i cant use char method to grab name and calculate total size...anyone can tell me any method to generate the report...ty for all help

Well if the total content is in a string or in a file i guess it wont be much trouble reading them in.

For the user. You can just search for a space in the string ' ' and then consider the next word as the user.

And for the number . You will first need to convert it into a integer.

You can do this by doing the following

//if Str contains the number
string Str="123";
int x=atoi(Str.c_str());

Thank you sky, but how would i bring the string and put each column into array so i can read them?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.