Re: General tree assignment in C



On Feb 1, 6:32 pm, Ed Prochak <edproc...@xxxxxxxxx> wrote:
On Feb 1, 2:53 am, kwikius <a...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

<...>

The above path is a relative path. An absolute path requires a node
that the relative path is applied to.

implementation detail.

You lost me. Which part is an implementation detail ?

<...>

There is no absolute need for polymorphic structures here. A leave is
merely a node with no children.

A directory can be empty
I hope you dont want "change_to_working_directory(file) to succeed?

Functionally you do have to treat them
differently.

They have some things in common too... "Polymorphic" :-)

<...>

Finally some means to represent a path. For simplicity a list of
strings works well

No it does not for this assignment.

List of strings seems relatively trivial in C...

#include "stdio.h"

struct path{
char ** path_list;
int num_elements;
};

int main()
{
char * path_list[] ={"my","projects","hello.cpp"};

struct path my_path;
my_path.path_list = path_list;
my_path.num_elements = 3;

int i;
for (i = 0; i < my_path.num_elements;++i){
printf("%s",my_path.path_list[i]);
if ( i <( my_path.num_elements-1)){
printf("/");
}

};
printf("\n");

<...>

... Whatever...

In C the vast proportion of your time will be spent implementing what
other languages provide as standard rather than solving the actual
problem.
<...>

This is a school assignment. the OP must use C so your > tooting the horn of C++ is not helpful.

Toot! Toot ! ... compiler may be a C++ compiler also.

:-)

The Pathname is only an artifact of the user interface, NOT an
inherent properety of file systems.

Users can always migrate to rival system with a nice UI I guess...

(Have you ever worked on a flat
file system?)

The spec describes a hierarchical file-system.

regards
Andy Little



.



Relevant Pages

  • Re: Read-only, as opposed to const member
    ... If making "colour" an int was not the right ... I would argue this goes beyond a mere implementation detail. ... or my second one which has public const member references ...
    (comp.lang.cpp)
  • Re: Nested function scope problem
    ... Gerhard Fiedler wrote: ... the following doesn't seem to be implementation detail ... #> (and rather a part of the language), ... int main ...
    (comp.lang.python)